moment.parseZone() 函数方法解析提供的字符串,并将生成的时刻保留在固定的时区中。此外,此方法分析字符串,但将生成的 Moment 对象保留在固定偏移量时区中,并在字符串中提供偏移量
- 语法
moment.parseZone() moment.parseZone(String)
- 参数
具有提供的偏移量的 固定偏移时区 - 返回类型
此函数将 Moment 对象返回到本地或 UTC 时间
这在正常的 Node.js 程序中不起作用,因为它需要一个外部js库来全局安装或在项目目录中安装
npm install moment
获取当前解析时区
const moment = require('moment');
var a = moment().parseZone();
console.log("Current parse Timezone: ",a)
输出
Current parse Timezone: Moment<2022-10-13T12:21:25+00:00>
解析时区
const moment = require('moment');
var a = moment("2022-01-01T00:00:00-16:00").utcOffset("2022-01-01T00:00:00-16:00");
var b = moment.parseZone("2022-01-01T00:00:00-16:00");
console.log("Current parse Timezone: ",a)
console.log("Current parse Timezone: ",b)
输出
Current parse Timezone: Moment<2022-01-01T00:00:00-16:00>
Current parse Timezone: Moment<2022-01-01T00:00:00-16:00>
© 版权声明
非商业转载或引用请标注本文链接,商业转载或引用请联系站长
部分文章内容可能来自互联网,如有侵权,请通过邮件联系
部分文章内容可能来自互联网,如有侵权,请通过邮件联系
THE END
暂无评论内容