In comp.lang.javascript message <b346a950-c2aa-40c2-9d2c-fee757bba96d@t2
g2000yqe.googlegroups.com>, Mon, 30 Aug 2010 14:33:42, Xerxes
I am trying to convert a date that I get from DB in the "Thu Aug 26
00:00:00 EDT 2010" format to mm/dd/yyyy.
I use d.format("mm/dd/yyyy") but I get 00/26/2010. What am I doing
wrong?
As at about 2010-08-31 19:25 UTC, AFAICS no-one has really attempted to
answer the explicit question.
Since the example date is in a (ludicrous) format commonly used in US
software and that format has been readable by JScript new Date(" ...
") for longer than I have been using JavaScript, it is safe to expect
that no browser will stop accepting it, with the desired meaning.
However, although the ECMA standard requires new Date(String) to
work, it does not specify any string formats.
If you have read the string into a Date Object, you can check the input
stage by using its default .toString method.
Opera 9.50 did not accept alphabetical local time offset designators,
which are intrinsically ambiguous. Opera 10.61 does, which is a pity.
I don't recall exactly when Opera changed.
What you did wrong :
You did not give the browser and OS versions; they often matter,
particularly with date strings.
You did not give a complete executable (by copy'n'paste without editing)
routine showing the problem and including ALL code including library
code.
You apparently did not try to locate the problem by examining the
intermediate value more directly.
You are apparently using some form of date library.
You are trying to generate a format which is not that recommended by ISO
8601, ANSI X3.30-1985(R1991), FIPS PUB 4-1 & 4-2, CSA Z234.5:1989.
You did not say that you had read the newsgroup FAQ.