0

How to change the format of:

--> var enterDate = '2016-01-15'; // to 2016-01-15T00:00:00.0000000+08:00 with JS syntax?

// I try these and none of these works out:

1) enterDate.format("yyyy-mm-ddT00:00:00.0000000+08:00");
console.log(enterDate);

2) enterDate.toLocaleFormat("%B %e, %Y %M:%S");

Thanks in advance.

2
Contributors
1
Reply
9
Views
2 Years
Discussion Span
Last Post by diafol
0
var dateString = '2016-01-15';
var d = new Date(dateString);
var output = d.getUTCFullYear() + "-" + ("0" + (d.getUTCMonth()+1)).slice(-2) + "-" + ("0" + d.getUTCDate()).slice(-2) + "T" + ("0" + d.getUTCHours()).slice(-2) + ":" + ("0" + d.getUTCMinutes()).slice(-2) + ":" + ("0" + d.getUTCSeconds()).slice(-2) + ("00" + d.getUTCMilliseconds()).slice(-3) + "0000+08:00";
console.log(output);

Not tested. You really want this to the closest 100 nanoseconds???

Edited by diafol

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.