admin管理员组文章数量:1410697
How to get year, month, day, hours, minute in milliseconds of the selected date and time in JavasScript?
var month = date.getMonth();
var day = date.getDay();
var year = date.getYear();
var hour= date.getHours();
var min= date.getMinutes();
All i want is timestamp...
How to get year, month, day, hours, minute in milliseconds of the selected date and time in JavasScript?
var month = date.getMonth();
var day = date.getDay();
var year = date.getYear();
var hour= date.getHours();
var min= date.getMinutes();
All i want is timestamp...
Share edited Mar 27, 2017 at 12:39 Sagar V 12.5k8 gold badges45 silver badges70 bronze badges asked Mar 27, 2017 at 12:23 Yogeshwar NairYogeshwar Nair 471 gold badge1 silver badge12 bronze badges 2- All in milliseconds ? – Pugazh Commented Mar 27, 2017 at 12:24
- the bination of this in milliseconds and date is already given and with current time i have to create the timestamp? – Yogeshwar Nair Commented Mar 27, 2017 at 12:34
2 Answers
Reset to default 2You can do it like this:
date.getTime()
All you want to get the timestamp in milliseconds is getTime()
function.
date = new Date();
console.log(date.getTime());
To get the timestamp for a particular date, pass the date and time in the format
mm/dd/yyyy hh:mm
to the Date constructor
date = new Date("03/27/2017 12:00");
console.log(date.getTime());
本文标签: datetimejavascript get monthyeardayhoursminute timestampStack Overflow
版权声明:本文标题:datetime - javascript: get monthyeardayhoursminute timestamp - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744882837a2630309.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论