0
我有日期變量在sapui5這樣的:Javascript中的日期轉換?
「週五1960年1月1日03:00:00 GMT + 0300(土耳其標準時間)」
,但我需要
「1960年1月1日」
格式我。如何能做到這一點?謝謝回答。
我有日期變量在sapui5這樣的:Javascript中的日期轉換?
「週五1960年1月1日03:00:00 GMT + 0300(土耳其標準時間)」
,但我需要
「1960年1月1日」
格式我。如何能做到這一點?謝謝回答。
您可以在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);
更妙的是:用'style:「medium」'替換'pattern:「dMYYYY'',它可以在全世界使用;) – Marc
完全同意,給出了一個答案,假設這個人想要某種原因的確切模式:) –