I want datetime in custom format as per below.
2019-01-24T05:52:29:420 +0000 GMT+0000
but when I try do it using below syntax I did not work.
var currentdate = new Date();
alert(currentdate);
Any help? Thanks
I want datetime in custom format as per below.
2019-01-24T05:52:29:420 +0000 GMT+0000
but when I try do it using below syntax I did not work.
var currentdate = new Date();
alert(currentdate);
Any help? Thanks
Look into Moment.js, you can format JS dates with this quite easily.
e.g:
moment().format('MMMM Do YYYY, h:mm:ss a'); // January 24th 2019, 5:13:29 pm
moment().format('dddd'); // Thursday
in your case:
moment(currentdate).format('the format you would like');
its very simple you just have to do currentdate.toISOString() which will return "2019-01-24T06:19:19.975Z", now its simple just remove last char from string and concat the other string part in it.
var currentdate = new Date().toISOString();
alert(currentdate.substr(0, currentdate.length-1)+' +0000 GMT+0000');