Converting timestamp from PST to UTC


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Converting timestamp from PST to UTC
# 1  
Old 10-14-2015
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), so now i need to convert it into UTC with the same format.

So for 2015101010 (PST) I need the output as (2015101017) UTC. Could someone through some lights here.

Thanks.
# 2  
Old 10-14-2015
What operating system and shell are you using?

And, what is the source of a timestamp that is producing a time on October 10th that is in PST rather than PDT? And the difference between PST and UTC is 8 hours; not 7. It looks like your example is trying to convert PDT or MST to UTC; not PST to UTC.
# 3  
Old 10-14-2015
Yes you are right my timestamp is in PDT and i want to convert it into UTC.
I will be getting this timestamp from another script with YYYYMMDDHH format and I am using linux bash shell.

Basically i am going to call some api to get some details but in the target system we have the data in UTC that's the reason I am trying to convert my PDT timestamp to UTC.

Thanks
# 4  
Old 10-15-2015
Disregarding midnight transition as well as month/year end, what keeps you from trying
Code:
DT=2015101010
echo $(( DT + 7 ))
2015101017

# 5  
Old 10-15-2015
Just some comments. Time is variable according to the time the time was seen.

There's a reason why you want all times in UTC, but even so, to get time based context into some kind of local representation means you can always do simple math (that evil daylight savings thing).

I guess what I'm trying to say is that in order to do this relatively well you may need to have time context depending on how far back the dates go. Simple math will work as long as we haven't been playing with time (again, talking primarily about daylight savings).

Even if this is fairly recent data, you may still have to account for daylight savings for those times if they cross those days. But like I said, those simple calculations become a bit harder if you cross a rule change for daylight savings.

Enjoy!

Oh.. and time is just a displacement, if you can write programs that don't care about what we call "time"... do it. But obviously we've given meaning to time... so we have expectations and dependencies built on it.
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

GMT to PST

99.60.97.205 - - GET /2009-03-29/world/impact.row.atlantic_1_rower-paul-ridley-cancer-research?_s=PM:WORLD HTTP/1.1 200 9386 www.abc.com Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; en-US) AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.107 Safari/534.13 ... (4 Replies)
Discussion started by: sandy1028
4 Replies

2. Shell Programming and Scripting

Find and Convert UTC Time to PST Time

Hello All - I have a script that grabs data from the net and outputs the following data 46029 46.144 -124.510 2010 07 26 22 50 320 4.0 6.0 2.2 9 6.8 311 1012.1 -0.9 13.3 13.5 13.3 - - 46041 47.353 -124.731 2010 07 26 22 50 250 2.0 3.0 1.6 8 6.4 - 1011.6 - ... (0 Replies)
Discussion started by: drexnefex
0 Replies

3. Shell Programming and Scripting

GMT to PST

I have a file which is tab delimited, it contains the GMT date. Please tell me how to convert from GMT to PST time and if the date and time is of 2 days ago from the current date store the lines in a file or else remove the line. 10.1.10.178 - - - 10.1.10.178 - - ... (2 Replies)
Discussion started by: sandy1028
2 Replies

4. 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

5. Programming

converting unix timestamp into readable format using c++

hi everyone, im new here and am in desperate need of help. I want to convert my 32 bit unix time stamp ' 45d732f6' into a readable format (Sat, 17 February 2007 16:53:10 UTC) using c++. I have looked around the interent but i just cant make sense of anything. All examples i can find just... (3 Replies)
Discussion started by: uselessprog
3 Replies

6. UNIX for Advanced & Expert Users

changing sys clock (PST to UTC)

Hi I'm trying to change my sys clock from PST to UTC. I've read the man date page it helpfully says :- -u, --utc, --universal print or set Coordinated Universal Time as root I have tried date --universal, date -u, date --utc, I have checked the /etc/sysinfo/clock file the... (5 Replies)
Discussion started by: OFFSIHR
5 Replies

7. UNIX for Advanced & Expert Users

Select entries between two dates by converting Unix timestamp in Oracle Database.

Hi, I need to select the entries between two dates from an Oracle db. The Oracle db has a column with Unix timestamps. I use the following querry, but it doesnt seem to be working as desired. select count(*) from reporter_status where to_char(FIRSTOCCURRENCE, 'mm-dd-yy') between ('08-07-06')... (1 Reply)
Discussion started by: amitsayshii
1 Replies
Login or Register to Ask a Question