获取现在和未来(过去)的时间函数

JavaScript基础 李晓兰

getTime() :可返回距 1970 年 1 月 1 日之间的毫秒数;

捕获1.PNG

捕获2.PNG

toLocaleString():可根据本地时间把 Date 对象转换为字符串,并返回结果

捕获1.PNG

捕获2.PNG

单位换算:1000毫秒 = 1秒;   60秒 = 1分钟;   60分钟 = 1小时;   24小时 = 1天; 365 | 366 = 1年;

将两种函数运用起来,可以获取现在和未来(过去)的时间;

捕获1.PNG

捕获2.PNG

捕获3.PNG

捕获4.PNG

还能输出{{restrictNumber}}个字符  
  • {{reply.author}}

    {{CommonUtil.formateDate(reply.ac_CommentDate).shortTime}}
  • 回复了{{Comments.author}} :