JavaScript - toLocaleFormat() 方法



描述

Javascript date toLocaleFormat() 方法使用指定的格式將日期轉換為字串。

注意 - 此方法可能不相容所有瀏覽器。

語法

其語法如下:

Date.toLocaleFormat()

引數詳情

formatString - 與 C 中 strftime() 函式期望的格式相同的格式字串。

返回值

返回格式化的日期。

示例

嘗試以下示例。

<html>  
   <head>
      <title>JavaScript toLocaleFormat Method</title>
   </head>
   
   <body>      
      <script type = "text/javascript">
         var dt = new Date(1993, 6, 28, 14, 39, 7);
         document.write( "Formated Date : " + dt.toLocaleFormat( "%A, %B %e, %Y" ) ); 
      </script>      
   </body>
</html>

輸出

Formated Date : Wed Jul 28 1993 14:39:07 GMT+0530 (India Standard Time)
javascript_date_object.htm
廣告