How can i frame current date & time in the xml standard dateTime format in shell script
2011-10-18T12:00:00.000000
I got up to the date format using the below code
date '+%Y'-'%m'-'%d'T
---------- Post updated at 09:10 AM ---------- Previous update was at 08:53 AM ----------
I got that by using the below code
date '+%Y'-'%m'-'%d'T'%T'.'%N'
can anyone confirm?
A date format string works just like the printf (either C or shell printf) format string.
date '+%Y-%m-%dT%T.%N'
Gives you the result you want, the way you did it was correct, but confusing for other coders. %N is not part of the POSIX standard, so this will only work for GNU date (Linux, mostly).
Thank you for your suggestion. Is there any replacement command for %N. Also i need to get the first six decimal points only. Please help.
It depends. What's your system?
Then you are fine. %N is available to you as Linux uses GNU date by default.