2017-06-23 73 views
0

我有日期变量在sapui5这样的:Javascript中的日期转换?

“周五1960年1月1日03:00:00 GMT + 0300(土耳其标准时间)”

,但我需要

“1960年1月1日”

格式我。如何能做到这一点?谢谢回答。

回答

2

您可以在sapui5中使用标准date format

在你的情况的编码将​​是这样的:

sap.ui.core.format.DateFormat.getDateInstance({pattern: "d.M.YYYY"}).format(inputdate); 

但更好的方法是,让系统选择基于用户的语言环境的日期格式模式:

sap.ui.core.format.DateFormat.getDateInstance({style: "medium"}).format(inputdate); 
+0

更妙的是:用'style:“medium”'替换'pattern:“dMYYYY'',它可以在全世界使用;) – Marc

+0

完全同意,给出了一个答案,假设这个人想要某种原因的确切模式:) –