I have a ISO DateTime string "2015-10-05T08:30:00" getting through REST request. Now I need to convert it into my local DateTime. The way I am trying

var isoDateTime = new Date("2015-10-05T08:30:00");
var localDateTime = isoDateTime.toLocaleDateString() + " " + isoDateTime.toLocaleTimeString();

Output is: 10/5/2015 2:30:00 PM.

Date is okay but the time is not. When I open this item in edit/display form, I got different date and it is actual date.

enter image description here

  • 2
    You might want to use moment.js and moment time zones, momentjs.com – Eric Alexander Oct 30 '15 at 19:22
  • I haven't used it yet, but I know many who have and swear by it. Date manipulation is the worst in JavaScript, compounded by all the different date/time settings available in SharePoint. – Eric Alexander Oct 30 '15 at 19:31
  • Me too! Now searching to use – Atish Dipongkor - MVP Oct 30 '15 at 19:32
  • Have to read the documentation... Looking for others ways or who already faced this problem. Thanks @EricAlexander – Atish Dipongkor - MVP Oct 30 '15 at 19:40

Found a magical solution! Date.parseLocale(value, formats) has solved my issue. There is no need to use third party libraries. See the details from msdn.

Use the pareseLocale function to create an object of type Date from a string. If you provide no custom formats, this function uses the Sys.CultureInfo.CurrentCulture property to determine the culture value.


value: A locale-specific string that represents a date.

formats(Optional): An array of custom formats.

Return Value

If value is a valid string representation of a date, an object of type Date; otherwise, null.

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.