如何在javascript中获取datetime? [英] How to get datetime in javascript?

查看:105
本文介绍了如何在javascript中获取datetime?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用格式31/12/2010 03:55 AM获取日期时间?

How to get date time in javascript with format 31/12/2010 03:55 AM?

推荐答案

语义上,你'可能寻找单行

Semantically, you're probably looking for the one-liner

new Date().toLocaleString()

其中格式化用户区域的日期。

which formats the date in the locale of the user.

真正寻找格式化日期的具体方式,我建议您使用 moment.js 库。

If you're really looking for a specific way to format dates, I recommend the moment.js library.

这篇关于如何在javascript中获取datetime?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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