1

I am saving the Time Zone as 'Default[(UTC+05:30)Chennai, Kolkata, Mumbai, New Delhi]'. As the exact conversion of UTC to Local time is happening in client side (js). While exporting the DateTime to an excel, I write the coding in appService itself. Due to time conversion is not happening in appService, I am getting the UTC time without converting to my time zone. I have given date.tolocaltime(); for conversion while running in local source conversion is happening, but the conversion is not happening after hosting the application. I have hosted my application on the cloud server (Azure)

CASE:

  1. DateTime saved in DB - '2018-03-01 19:11:34.000'
  2. Actual Date - '02-03-2018 00:43:22' (dd-mm-yyyy)
  3. Showing Exported Date as - '2018-03-01'
Vivek Nuna
  • 25,472
  • 25
  • 109
  • 197

1 Answers1

1

Better you store time in UTC format in the database and show local time to the end user because it will be unique across all timezone so you will not have to worry about the locale of the user.

You have to options to do this.

  1. Get time from the database and convert it to local time like this.

    TimeZone.CurrentTimeZone.ToLocalTime(date);
    
  2. Convert the UTC time to local time in Angular side before rendering to the end user. I have already answered here.
Vivek Nuna
  • 25,472
  • 25
  • 109
  • 197