问题描述
我有一个datetime对象,其值如下
I have a datetime object and its value is as follows
2017-03-16T17:46:53.677
有人可以让我知道如何将其转换为dd / mm / yyyy hh:mm:ss格式
我在Lott上进行了搜索,但找不到此特定输入的格式转换。
Can someone please let me know how to convert this to dd/mm/yyyy hh:mm:ss formatI googled a lott and could not find format conversion for this particular input.
推荐答案
您可以按照其他文章中所述完全格式化字符串。但是我认为您最好在date对象中使用语言环境功能?
You can fully format the string as mentioned in other posts. But I think your better off using the locale functions in the date object?
var d = new Date("2017-03-16T17:46:53.677");
console.log( d.toLocaleString() );
的方式。欧洲日期为 dd / mm / yyyy
,美国日期为 mm / dd / yyyy
。
Just so you know the locale
function displays the date and time in the manner of the users language . European date is dd/mm/yyyy
and US is mm/dd/yyyy
.
var d = new Date("2017-03-16T17:46:53.677");
console.log(d.toLocaleString("en-US"));
console.log(d.toLocaleString("en-GB"));
这篇关于以dd / mm / yyyy hh:mm:ss格式转换日期对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!