datetime - Where can I find documentation on formatting a date in JavaScript? -


I noticed that JavaScript's new date () function is very much in accepting the date in many formats It's just clever. Xmas95 = New date ("25 December, 1995 23:15:00") Xmas95 = New Date ("2009 06 12,12: 52: 39") Xmas95 = New Date (" New Date () While calling the function, I did not see any valid string formats anywhere.

/ P>

This is a string Is to convert to a date. If we look at the opposite direction, i.e., the date object is converted to a string, so far I was under the assumption that kis in javascript There is no built-in API for formatting the date object in a string.

Editor's note: The following approach is an inquiring attempt to work on a particular browser But not works normally; see answers given on this page to see some real solutions.

Today , I'm played with the date toString () To clear and surprisingly it serves strings for the purpose of formatting a date.

  var d1 = new date (); D1.toString ('yyyy-MM-dd'); // Returns "2009-06-29" in Internet Explorer, but not for Firefox or Chrome D1. Trusting ('DDDD, MMMM, YY') // Internet Explorer "Monday, June 29, 2009" Firefox or not Chrome  

Here too, I am using any document in all ways Can not find, so that we can format the date object in a string.

Object

I love and .

In fact, you have three ways and you have to combine stars for yourself: (getDate) / / returns returns getMonth () // returns The month gets FullYear () // Returns the year

Example:

  



  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -