1var currentTimeInSeconds=Math.floor(Date.now()/1000); //unix timestamp in seconds
2var currentTimeInMilliseconds=Date.now(); // unix timestamp in milliseconds
1let date1 = "15/03/2020";
2let date2 = "15:03"
3
4//to timestamp
5var date = date1.split("/")
6date= date[2] + "-" + date[1] + "-" + date[0]
7date = new Date(date + "T" + date2 + ":00")
8console.log(date.getTime())
9
10//to String
11date = date.toLocaleString()
12
13console.log(date)
1var myDate = new Date("Jul 21, 2013");
2var date = myDate.getDate();
3var month = myDate.getMonth();
4var year = myDate.getFullYear();
5
6function pad(n) {
7 return n<10 ? '0'+n : n
8}
9
10var ddmmyyyy = pad(date) + "-" + pad(month + 1) + "-" + year;
11
1function toTimestamp(strDate){
2 var datum = Date.parse(strDate);
3 return datum/1000;
4}
5alert(toTimestamp('02/13/2009 23:31:30'));
6