3

I have custom column, interview date, in custom list and I am storing date and time in column. When I fetch interview date data then it will return wrong time.

If I store value in field 26 May 2016 12.00.00 AM then it will return 26 May 2016 12.30.00 (PM 24 hour date format), means It is giving actual time + 12.30 hour. Currently I am using Office 365 and site's time zone is set to Indian standard time and also system time is set to India.

What is best solution for this? I have to built script that can be used in any country.

  • Can you post relevant code. – Amal Hashim May 27 '16 at 12:55
  • DateTime is stored in UTC, so when setting time, you need to convert to UTC first. Otherwise, it might think the date provided was in UTC, and then try to convert to IST on retrieval. Though, this should result in a difference of 5.5 hours, not 12.5. – wjervis May 27 '16 at 14:29
  • take a look at moment.js – Aveenav May 27 '16 at 16:12
0

You can use momentjs to do the conversions to the local time. http://momentjs.com/timezone/docs/#/using-timezones/

This is an example from the documentation:

var m = moment.tz("2013-11-18 11:55", "America/Toronto");

You'll need to look through the documentation to find out how best to meet your needs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.