In the same spirit as discussed here, is there a recommended way to generate / parse dates from within a bash script so that it can be interfaced to Javascript Date?
To be precise, I get this strings when doing json encoding of a Javascript Date object:
2011-10-31T10:23:47.278Z
I could put together a bash hack to generate / parse that date format, but I would prefer to avoid reinventing the wheel. Does somebody have a working solution?
I am more interested in the “generating” side: I want to generate current dates from a bash script and save them in a json document (couchdb) so that they can be automatically ordered by the view engine.
The closest I am coming is this:
Which gives this output:
I do not like that I have to put the
T, theZand the milliseconds to 0 manually (I can use%Nfor nanoseconds, and truncate withsedor whatever, but seems like overkill just to get millisecond precission), and I was hoping that there would be a built-in format token fordatewhich would produce that UTC date. I assumed – wrongly it seems – that the format is common enough that it can be specified with just one format token.