JavaScript 格式化

1,Date

var timestamp=new Date().getTime();//取得当前时间戳
var now = new Date(timestamp); //取得当前时间
now.setHours(0,0,0,0);//0点
now.setHours(23,59,59,999)//24点
var yestoday=new Date(timestamp-24*60*60*1000);//昨天
var tomorrow=new Date(timestamp+24*60*60*1000);//明天
now.setDate(1); //当月1日
var timestart = now.getTime();//当月1日时间戳
now.setMonth(now.getMonth() + 1); //下月1日
now.setDate(0); //当月最后一日
var timeend = now.getTime();//当月月末时间戳
View Code

 

posted @ 2024-08-06 10:50  ZainXiao  阅读(14)  评论(0)    收藏  举报