How would you compute an xsd:dateTime in a shell script.

I can see several candidates :

$ date --iso-8601=seconds -u
2013-01-31T16:05:35+0000

but this option seems deprecated, or :

$ date --rfc-3339=seconds -u
2013-01-31 16:06:29+00:00

Both don't return the same result... so... are there any hints I've overlooked ?

asked 31 Jan '13, 11:09

olberger's gravatar image

olberger
938
accept rate: 0%


Both are wrong in the detail for an xsd:dateTime.

--iso-8601=seconds has timezone as 0000, not 00:00

--rfc-3339=seconds has a space

take control and use a format:

date +'%Y-%m-%dT%H:%M:%S%:z'

or more concisely:

 date '+%FT%T%:z'
link

answered 31 Jan '13, 13:56

AndyS's gravatar image

AndyS ♦
13.0k37
accept rate: 32%

edited 31 Jan '13, 14:00

1

Perfect. Thanks alot.

(31 Jan '13, 14:42) olberger olberger's gravatar image
1

@olberger If this answer solved your problem don't forget to accept it, click the tick mark under the vote up/down buttons

(01 Feb '13, 05:03) Rob Vesse ♦ Rob%20Vesse's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×18
×17

Asked: 31 Jan '13, 11:09

Seen: 662 times

Last updated: 01 Feb '13, 05:03