tags:

views:

34

answers:

2

I have a CGI script that will convert a given string to a date/time using the unix date command. I'm looking for a format that can easily be embedded to a URL without the need for escaping with a %20. The client that is building the date/time into the URL does not have a conversion to unix time (seconds since epoch) and does not have a way to convert to the offset from zulu (ISO8601 will not work). However, it is possible to reformat the date/time used to build the URL in many other ways.

Are there any other options to build a datetime in a non-spaced format?

A: 
$ date "+%F-%T"
2010-10-25-16:23:14
chrisaycock
Thank you for response but I still need a timezone. Also, `date -d "2010-10-25-16:23:14"` didn't work.
User1
A: 

I found a simple work around. Simply use underscores for spaces and do a tr in the CGI script before converting to a date. It looks something like this:

stamp="$(echo $stamp|tr _ ' '|xargs -0 date -d)"

Then use a date that looks something like this:

26_Oct_2010_11:57:56_CDT

which converts to:

date -d "26 Oct 2010 11:57:56 CDT"

User1