转换2022-04-20T17:00:00.000Z到TimePicker格式

发布于 2025-01-26 00:01:42 字数 206 浏览 2 评论 0原文

我的价值像2022-04-20T17:00:00.000Z一样

如何转换?

I have a value like 2022-04-20T17:00:00.000Z, I want to convert it like as in image which is only accepts in antd timepicker,
enter image description here

How to convert?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

笑叹一世浮沉 2025-02-02 00:01:42

安装MOMM库:

npm安装矩

然后将其导入您的项目

从“ MONM MONM”

使用它来格式化日期

const MomentDate = Moment(“ 2022-04-20T17:00:00.000Z”)

Install the moment library:

npm install moment

Then import it into your project

import moment from "moment"

use it to format your date

const momentDate = moment("2022-04-20T17:00:00.000Z")

你爱我像她 2025-02-02 00:01:42

您可以为此使用时刻。

const date = "2022-04-20T17:00:00.000Z";
const timePickerMomentObj = moment(date);

有关更多datils,您可以请访问MORM

You can use the moment for this.

const date = "2022-04-20T17:00:00.000Z";
const timePickerMomentObj = moment(date);

For more datils, you can visit moment document

〃安静 2025-02-02 00:01:42

new Date('2022-04-20T17:00:00.000Z');

这样

您可以简单地new Date (

var d = new Date('2022-04-20T17:00:00.000Z');
console.log(d.getUTCHours()); // Hours
console.log(d.getUTCMinutes()); //Minutes
console.log(d.getUTCSeconds()); //Seconds

you can simply new Date()

new Date('2022-04-20T17:00:00.000Z');

like this to convert given timestamp into required format

then you can also extract only the part you want

var d = new Date('2022-04-20T17:00:00.000Z');
console.log(d.getUTCHours()); // Hours
console.log(d.getUTCMinutes()); //Minutes
console.log(d.getUTCSeconds()); //Seconds
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文