物料UI时间选择器UTC

物料UI时间选择器UTC

本文介绍了物料UI时间选择器UTC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在浏览文档,并独自使用材料ui进行游戏,我看不到任何能够选择UTC时间的设置.即使我传入UTC日期对象,它也始终默认为时间选择器的本地时区.有人知道解决方法吗?

I've been looking through the docs and playing around on my own with material ui and I do not see any sort of setting to be able to choose the time in UTC. It always defaults to my local timezone for the time picker, even if I pass in a UTC Date object. Is anyone aware of a workaround for this?

推荐答案

唯一的方法是将Date格式化为String,然后使用moment-timezone

Only way is to format your Date into String then use moment-timezone

var newYork    = moment.tz("2014-06-01 12:00", "America/New_York");

var losAngeles = newYork.clone().tz("America/Los_Angeles");

var london     = newYork.clone().tz("Europe/London");

我希望它将在material-ui中得到支持

I hope it will be support in material-ui

这篇关于物料UI时间选择器UTC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 02:57