在伦敦 - BST的时刻js utc()时间 [英] Moment js utc() time in london - BST

查看:105
本文介绍了在伦敦 - BST的时刻js utc()时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用momentjs lib来更新某些ajax动作的文本。我需要做的是设置当前日期&在伦敦的时间。我正在使用moment.utc()函数,但由于夏天我只有一个小时。

I'm using momentjs lib to updated text on some ajax action. What I need to do is to set a current date & time in london. I'm using moment.utc() function but because of the summer time I'm one hour out.

例如在14:26运行它

For example running this on 14:26

console.log( moment.utc().format('HH:mm:ss') );

我得到13:26:53。

I'm getting 13:26:53.

关于如何解决这个问题的想法?

Any idea on how to fix this?

推荐答案

你能来吗?使用 momentJS时区

moment()。tz('Europe / London ');

moment().tz('Europe/London');

编辑:如果你试图在没有看到链接的情况下使用它,那么你需要包含一个单独的库。

In case you try to use this without seeing the link, it's a separate library you have to include.

这篇关于在伦敦 - BST的时刻js utc()时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆