How can I convert normal date 2012.08.10
to unix timestamp in javascript?
Fiddle: http://jsfiddle.net/J2pWj/
I\'ve se
var d = '2016-01-01T00:00:00.000Z';
console.log(new Date(d).valueOf()); // returns the number of milliseconds since the epoch
new Date('2012.08.10').getTime() / 1000
Check the JavaScript Date documentation.
You can do it using Date.parse() Method.
Date.parse($("#yourCustomDate).val())
Date.parse("03.03.2016") output-> 1456959600000
Date.parse("2015-12-12") output-> 1449878400000
convert timestamp to unix timestamp.
const date = 1513787412;
const unixDate = new Date(date * 1000);// Dec 20 2020 (object)
to get the timeStamp after conversion
const TimeStamp = new Date(date*1000).getTime(); //1513787412000
You can use Date.parse(), but the input formats that it accepts are implementation-dependent. However, if you can convert the date to ISO format (YYYY-MM-DD), most implementations should understand it.
See Why does Date.parse give incorrect results?.