js中获取时间戳的五种方法
来源:互联网 发布:linux alsa声卡驱动 编辑:程序博客网 时间:2024/05/23 11:21
var fs=require("fs")
fs.stat("f:\\桌面\\www", function(err,stat)
{
if(err)
{
console.info(err);
}
console.info(stat.ctime.valueOf()); //获取日期对象的时间戳 单位毫秒
console.info(stat.ctime.getTime()); // 获取日期对象的时间戳 单位毫秒
console.info(Date.parse(stat.ctime.toString())); //获取日期对象(字符串)的时间戳 单位毫秒,但是精度是秒
console.info(Date.UTC(stat.ctime.getUTCFullYear(),stat.ctime.getUTCMonth(),stat.ctime.getUTCDate(),stat.ctime.getUTCHours(),stat.ctime.getUTCMinutes(),stat.ctime.getUTCMilliseconds()));
//根据日期对象的分量获取时间戳 单位毫秒,但是精度到秒
console.info(fs._toUnixTimestamp(stat.ctime)); // 获取日期对象的时间戳(node专有) 单位为秒,精度到毫秒
}
);
fs.stat("f:\\桌面\\www", function(err,stat)
{
if(err)
{
console.info(err);
}
console.info(stat.ctime.valueOf()); //获取日期对象的时间戳 单位毫秒
console.info(stat.ctime.getTime()); // 获取日期对象的时间戳 单位毫秒
console.info(Date.parse(stat.ctime.toString())); //获取日期对象(字符串)的时间戳 单位毫秒,但是精度是秒
console.info(Date.UTC(stat.ctime.getUTCFullYear(),stat.ctime.getUTCMonth(),stat.ctime.getUTCDate(),stat.ctime.getUTCHours(),stat.ctime.getUTCMinutes(),stat.ctime.getUTCMilliseconds()));
//根据日期对象的分量获取时间戳 单位毫秒,但是精度到秒
console.info(fs._toUnixTimestamp(stat.ctime)); // 获取日期对象的时间戳(node专有) 单位为秒,精度到毫秒
}
);
0 0
- js中获取时间戳的五种方法
- JS中获取时间的方法
- JS获取当前时间戳的方法
- js获取时间戳的方法
- JS获取当前时间戳的方法
- JS获取当前时间戳的方法
- JS获取当前时间戳的方法
- JS获取当前时间戳的方法
- JS获取当前时间戳的方法
- JS获取当前时间戳的方法
- JS获取当前时间戳的方法
- JS获取当前时间戳的方法
- JS获取当前时间戳的方法
- JS获取当前时间戳的方法
- js获取当前时间戳的方法
- JS获取当前时间戳的方法
- JS获取当前时间戳的方法转换时间戳
- java中获取时间戳的方法
- php开发小白上手体验
- java几个问题
- centos maven配置
- 鸽笼原理及其应用
- ubuntu运行android studio出错unable to run mksdcard
- js中获取时间戳的五种方法
- 适配 react web
- Leetcode Sparse Matrix Multiplication
- Android通知栏微技巧,那些你所没关注过的小细节
- react 常用命令
- C++基础备忘
- Swift学习之三:整型与浮点型
- 让jsp支持EL
- 使用MyBatis(六)delete