You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Cannot correctly convert to UTC (uses server's time zone)
30
+
var utc = dt?.ToUniversalTime();
31
+
}
32
+
}
33
+
```
34
+
35
+
You can use `BlazorLocalTime` to solve these problems.
36
+
37
+
## Setup
11
38
Install `BlazorLocalTime` from [NuGet](https://www.nuget.org/packages/BlazorLocalTime):
12
39
13
40
```bash
@@ -77,51 +104,7 @@ Input forms also support separate date and time inputs:
77
104
}
78
105
```
79
106
80
-
## Using with UI Libraries
81
-
82
-
The `LocalTimeForm` component can be used with various UI libraries to create forms that handle local time input.
83
-
Below are examples using [MudBlazor](https://mudblazor.com/), [Fluent UI](https://www.fluentui-blazor.net), and [Ant Design Blazor](https://antblazor.com/) components.
> Since the demo site is running on `WebAssembly`, the time zone of RunTime normally matches the browser's time zone and should not work well.
167
+
Therefore, the above function is executed to force the time zone on the runtime side to be fixed to UTC.
168
+
169
+
> [!WARNING]
170
+
> This feature is intended for testing only. It is not recommended to change `TimeZoneInfo.Local` in production applications.
171
+
172
+
169
173
## Reference
170
174
171
175
[This article](https://www.meziantou.net/convert-datetime-to-user-s-time-zone-with-server-side-blazor-time-provider.htm) was used as a major reference. I would like to express my gratitude for the reference article.
Due to implementation limitations, the <code>Today</code> and <code>Now</code> buttons reference the server-side current time and do not work as expected. <br/>
169
+
Therefore, it is recommended to hide these buttons.
0 commit comments