I have only implemented a simple
format method that takes a
Date object and returns a formatted version of it. Every pattern
letter except z is implemented; I don't believe the information necessary to
documentation for details of all the possible pattern letters.
UPDATE 6 September 2006
work in Internet Explorer 5 on Windows because the
exec method of regular expressions doesn't
respect the global flag in IE5. There was also a bug affecting the implementation of pattern
UPDATE 6 February 2007
I believe that this version works in all Mozilla-based browsers including Netscape 6+ and Firefox / Firebird / Phoenix, IE5+ (Windows; untested on the Mac), Konqueror 3+, Safari 1.3+, Opera 7+. I'm sure it works on earlier versions of most of these browsers too, I just haven't been able to test on everything.
var sdf = new SimpleDateFormat("yyyy.MM.dd G 'at' HH:mm:ss"); document.write(sdf.format(new Date())); sdf = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z"); document.write(sdf.format(new Date()));