

Both are same messages but the time is differ. I am reuuning my application in local machine it shows correct time as shown in figure 1. When i see the same message through hosted link its shows the wrong time as shown in figure 2.
What is reason for this problem? How to solve this issue?
Satya KarkiPosted Feb 25, 2023, 6:01 AM
Hi, seems like your local machine is in one timezone, and hosted application is in another time zone. For example, you are in the Indian time zone, and hosted app is in the Singapore time zone. Have you hosted your app in the cloud?
Make sure, your local device timezone and hosted server time zone similar.
Rajeev KumarPosted Mar 2, 2023, 9:42 AM
Your local time is your system time. Check the timezone in your operating system. The server time you are referring is according to the timezone in your server configuration files.
Make sure you have operating system timezone and your server timezone similar.
Jignesh KumarPosted Feb 26, 2023, 8:59 AM
Hello Gopi,
It is due to time zone difference in your development system and hosted environment. To resolve this one please refer this link,
https://www.c-sharpcorner.com/UploadFile/c25b6d/various-operations-performed-on-timezoneinfo-using-C-Sharp/
https://learn.microsoft.com/en-us/dotnet/standard/datetime/converting-between-time-zones
Tuhin PaulPosted Feb 25, 2023, 3:16 PM
Hi Gopi,
To solve this issue, you can either configure the time zone on the server to match your local time zone or adjust the time zone setting in your application to display the time in the server's time zone.
One way to adjust the time zone setting in your application is to use the TimeZoneInfo class in C#. You can retrieve the local time zone on the server using the TimeZoneInfo.Local property and then use the ConvertTimeFromUtc method to convert the UTC time to the local time zone.
Here's an example:
You can then display the localTime value in your application to show the time in the server's time zone.
Alternatively, you can use the JavaScript Date object to display the time in the user's local time zone, regardless of the server's time zone. You can retrieve the UTC time from the server and then use JavaScript to convert it to the user's local time zone.
Here's an example:
In this example, the user's local time zone is set to 'America/New_York'. You can replace this with the appropriate time zone for your application.
Mukesh SagarPosted Feb 25, 2023, 3:09 PM
Use the UTC Time in the code.
GopiPosted Feb 25, 2023, 10:19 AM
But I coded to localize the time based on user machine.