แปลงเป็นวันที่วันที่และเวลาจาวาสคริปต์
// human date --> timestamp
function toTimestamp(strDate){
var datum = Date.parse(strDate);
return datum/1000;
}
alert(toTimestamp('02/13/2009 23:31:30'));
js แปลงเป็นวันที่วันที่และเวลา
const timestamp = new Date().getTime() // return timestamp in miliseconds
แปลงเป็นวันที่และเวลาเดทกับ js
var date = new Date("2016-07-27T07:45:00Z");
However, you can run into trouble when you do not provide the timezone explicitly!
แปลงเป็นวันที่วันที่และเวลาจาวาสคริปต์
const toTimestamp=(strDate)=>{
var datum = Date.parse(strDate);
return datum/1000;
}
console.log(toTimestamp('02/13/2009 23:31:30'));
แปลงเป็นวันที่และเวลาเดทกับจาวาสคริปต์
javascriptCopyvar timestamp = 1607110465663
var date = new Date(timestamp);
console.log("Date: "+date.getDate()+
"/"+(date.getMonth()+1)+
"/"+date.getFullYear()+
" "+date.getHours()+
":"+date.getMinutes()+
":"+date.getSeconds());
จาวาสคริปต์วันที่และเวลาที่จะเดท
function timeConverter(UNIX_timestamp){
var a = new Date(UNIX_timestamp * 1000);
var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
var year = a.getFullYear();
var month = months[a.getMonth()];
var date = a.getDate();
var hour = a.getHours();
var min = a.getMinutes();
var sec = a.getSeconds();
var time = date + ' ' + month + ' ' + year + ' ' + hour + ':' + min + ':' + sec ;
return time;
}
console.log(timeConverter(0));