JRS: In article <11*********************@u72g2000cwu.googlegroups. com>,
dated Mon, 8 May 2006 06:52:47 remote, seen in
news:comp.lang.javascript,
ah*****@gmail.com posted :
var myDate= new Date();
This gives me the format
Mon May 08 2006 21:51:31 GMT+0800 (China Standard Time)
I was thinking if i write my own function to achieve 2006-05-08
21:51:31 ?
Methods giving that can be found via the newsgroup FAQ, see sig below.
You have not said whether you want civil time or UTC. Seek one of
these, where implementation is by adding a Method to the Date Object.
new Date().ISOlocalDTstr() // 2006-05-08 20:12:44
new Date().UTCstr() // 2006-05-08 19:13:16
Basics of code is readily seen in js-nclds.htm .
If your are writing only for local use, and if the local settings are
sensibly in conformity with ISO 8601, then consider
new Date().toLocaleString() // 05/08/2006 20:18:03
Note, of course, that in my system Microsoft has not got it right.
Erwin, Matt : you omitted to notice the absence of a central colon.
OP : Date Objects do not have a format, other than IEEE Double of
milliseconds from UTC 1970.0.
Randy : He wants date, not Day-of-Week. Javascript getYear, Day-of-Week
and Month are non-standard; other results are normal, without improper
use of zero.
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.