Visit Our UNIX and Linux User Community


CST to UTC conversion


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting CST to UTC conversion
# 1  
Old 08-31-2009
CST to UTC conversion

Hi ALL,

In a file i have the date and time as:
Code:
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

Last edited by Yogesh Sawant; 04-14-2011 at 09:22 AM.. Reason: added code tags
# 2  
Old 08-31-2009
google "epoch conversion"
# 3  
Old 09-01-2009
from date manual
Code:
-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
Code:
date -d "2009-04-28 23:10:05 CST - 8 hours" +"%s"

# 4  
Old 09-02-2009
when i try in korn shell i am getting error like this:

Code:
$ 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.

Last edited by Yogesh Sawant; 04-14-2011 at 09:23 AM.. Reason: added code tags
# 5  
Old 09-02-2009
play around with Timezone..
Code:
-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..
Code:
utz=`TZ=UTZ date`

# 6  
Old 09-02-2009
When i checked this way i am getting from GMT to CST its not converting. is it due to any server settings problem?
Code:
$ 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


Last edited by Yogesh Sawant; 04-14-2011 at 09:23 AM.. Reason: added code tags
# 7  
Old 09-02-2009
seems like GMT and UTZ are same on my testing
Code:
-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$


Previous Thread | Next Thread
Test Your Knowledge in Computers #364
Difficulty: Medium
vi first appeared in 1BSD.
True or False?

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

UTC to GPS

Gents, Kindly can u help with this. I would like to get GPS time from UTC Input 17/11/27 03:13:50:480000 17/11/27 03:12:54:380000 17/11/27 03:14:39:980000 output desired. 17/11/27 03:13:50:480000 1195787648480000 17/11/27 03:12:54:380000 1195787592380000 17/11/27... (6 Replies)
Discussion started by: jiam912
6 Replies

2. Solaris

Convert GMT date and time to CST

I need away to convert the following GMT date and time value RAW_TME= 042720171530 "mmddccyyhhmm" to Localhost time. In this case it is in central time. Here is what I came up with but it does not look efficient: RAW_TME=042720171530 logmm=`echo $RAW_TME | cut -c1-2` logdd=`echo $RAW_TME |... (4 Replies)
Discussion started by: mrn6430
4 Replies

3. Shell Programming and Scripting

Converting timestamp from PST to UTC

I need to convert the given datetime from PST to UTC, i gone through multiple forum examples but everywhere it mentioned about converting the server datetime. So could someone help me on this. I will be getting arguments for my script in the format of yyyymmddhh (eg:2015101004 - it will be pst),... (4 Replies)
Discussion started by: close2jay
4 Replies

4. Shell Programming and Scripting

Need to find the .cst file in UNIX

I need to find out the .cst file in my unix. wat would be the command to find it out where it wil present in unix (8 Replies)
Discussion started by: ramkumar15
8 Replies

5. Shell Programming and Scripting

Convert UTC time to Date

Hi, I need to convert a number representing time in UTC seconds to a date. Ex: 3BE0082C --> Oct 31 2001 15:31:08 I have tried the following perl command but it gives a different answer? $ perl -e 'print scalar localtime(shift), "\n"' 3BE00B2C Thu Jan 1 03:00:03 1970 Any ideas? Thanks. :) (10 Replies)
Discussion started by: GNMIKE
10 Replies

6. Shell Programming and Scripting

Converting timestamps to UTC in bash

Hello, I am trying to figure out a way to convert the timestamps in a dataset from one timezone (which has daylight savings) to UTC. 2009-02-25 23:57:22,000D60727B89,221.16.86.23,SYSTEM1What would be the best way to approach this? (3 Replies)
Discussion started by: hazno
3 Replies

7. AIX

Utc

Is there an AIX command that displays the date mode so I can see if we have universal time code on? There's a vms command to tell you this but I have not been able to find a similar AIX command. (0 Replies)
Discussion started by: cchiang12
0 Replies

Featured Tech Videos