CST to UTC conversion

Hi ALL,

In a file i have the date and time as:

2009-04-28 23:10:05 CST

My Local Unix server time is in UTC.

Now i need to convert the above date and time in the file to UTC timezone and convert to number of seconds.

Kindly suggest me on this,

---------- Post updated at 05:13 AM ---------- Previous update was at 03:35 AM ----------

Can anyone suggest me on the above query. its urgent

google "epoch conversion"

from date manual

-bash-3.2$ date -d "2009-04-28 23:10:05 CST" +"%s"
1240981805
-bash-3.2$

you can also do arithmetic operations i dont know what UTZ is just subtract/add hours in the timezone

date -d "2009-04-28 23:10:05 CST - 8 hours" +"%s"

when i try in korn shell i am getting error like this:

$ date -d "2009-04-29 05:12:05 UTC"
date: illegal option -- d
usage:  date [-u] mmddHHMM[[cc]yy][.SS]
        date [-u] [+format]
        date -a [-]sss[.fff]
$ date -d "2009-04-28 23:10:05 CST - 8 hours" +"%s"
date: illegal option -- d
usage:  date [-u] mmddHHMM[[cc]yy][.SS]
        date [-u] [+format]
        date -a [-]sss[.fff]

In file i have "2009-04-28 23:10:05 CST"
My local server has UTC time. what i need to do is i need to wait till the date and time of the file comes and once it encounters this date and time then i need to start processing further.
The problem is i m unable to convert my server's UTC time to CST, so i need to convert CST to UTC date and time.

play around with Timezone..

-bash-3.2$ date
Wed Sep  2 12:24:48 EEST 2009
-bash-3.2$ x=`TZ=GMT-2 date`
-bash-3.2$ echo $x
Wed Sep 2 11:25:13 GMT 2009
-bash-3.2$ x=`TZ=UTZ date`
-bash-3.2$ echo $x
Wed Sep 2 09:25:54 UTZ 2009
-bash-3.2$

this is probably the best for you..

utz=`TZ=UTZ date`

When i checked this way i am getting from GMT to CST its not converting. is it due to any server settings problem?

$ date
Wed Sep  2 10:01:33 UTC 2009
$ utz=`TZ=UTZ date`
$ echo $utz
Wed Sep 2 10:01:43 GMT 2009
$ utz=`TZ=CST date`
$ echo $utz
Wed Sep 2 10:02:02 GMT 2009

seems like GMT and UTZ are same on my testing

-bash-3.2$ x=`TZ=UTZ date`
-bash-3.2$ echo $x
Wed Sep 2 10:24:40 UTZ 2009
-bash-3.2$ x=`TZ=GMT date`
-bash-3.2$ echo $x
Wed Sep 2 10:24:50 GMT 2009
-bash-3.2$