conversion from EPOCH timestamp to local time zone


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting conversion from EPOCH timestamp to local time zone
# 1  
Old 02-17-2006
MySQL conversion from EPOCH timestamp to local time zone

hello gurus,

i want a perl/shell script which once invoked should convert a set of EPOCH timestamps to local time ( IST..i want) .

how does it work ,i have an idea on that..but writing a perl/shell script for it is not possible for me...so i need help for the same.

my exact requirement is like this:
i would get a file containing 'n' EPOCH numbers & my script should convert these numbers into local time (IST) ( o/p we get when we type "date" command on prompt) .

locale on my server is set to IST.

thanks & regards
abhijeet
# 2  
Old 02-17-2006
What os do you have ?

On a linux machine with GNU date, this can be done.

Code:
date -d '1970-01-01 UTC 1140164951 seconds' +"%a %b %d %T %Z %Y"

Replace 1140164951 with your epoch format time.

Something like

Code:
while read epoch_date
do
echo $(date -d "1970-01-01 UTC $epoch_date seconds" +"%a %b %d %T %Z")
done < input.txt

Not tested. If it doesnt work, play around with the double quotes that surround +"%a %b %d %T %Z".

Last edited by vino; 02-17-2006 at 04:34 AM..
# 3  
Old 02-17-2006
MySQL

solaris 8.0

i know one command:

bash$ perl -e '$date = localtime(xxxxxxxxxx);print "$date\n";'
where xxxxxxxxxx is epoch timestamp.

it works ,i guess...
how do i put it in a script where my input is a text file containing a column of EPOCH numbers?

how do i get the o/p? can v have the o/p in a diffrent file ? if yes,how?
can v take the o/p in excel ?

i m blank on "perl" scripting.

abhijeet
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

GMT to local Time conversion

How can I convert the following date format: New Log Date = 2016-12-30 23:50:33 GMT from GMT time to local time? Thanks (13 Replies)
Discussion started by: mrn6430
13 Replies

2. Shell Programming and Scripting

Date Time Zone Conversion (backwards of what I want)

I am trying to convert local time to time in Ireland. Instead it is going the opposite direction (taking the local time as it if were in Ireland and displaying that the time would be here). $ echo "$TZ"; date; date --date='TZ="Europe/Dublin" '"$(date)" America/Phoenix Mon, Apr 13, 2015... (7 Replies)
Discussion started by: Michael Stora
7 Replies

3. Programming

Python conversion to epoch time

Hi. I have timestamps that I am trying to convert to epoch time. An example: I am trying to convert this to an epoch timestamp but have one little glitch. I have this: import time date_time = '' pattern = '' epoch = int(time.mktime(time.strptime(date_time, pattern))) print epoch... (1 Reply)
Discussion started by: treesloth
1 Replies

4. UNIX for Dummies Questions & Answers

Condition based on Timestamp (Date/Time based) from logfile (Epoch seconds)

Below is the sample logfile: Userids Date Time acb Checkout time: 2013-11-20 17:00 axy Checkout time: 2013-11-22 12:00 der Checkout time: 2013-11-17 17:00 xyz Checkout time: 2013-11-19 16:00 ddd Checkout time: 2013-11-21 16:00 aaa Checkout... (9 Replies)
Discussion started by: asjaiswal
9 Replies

5. Shell Programming and Scripting

Shell Script for Epoch Time Conversion

Hi there I came across this script online to convert Epoch time to proper date format, but I am receiving the following error Also, I have HISTTIMEFORMAT set in user's .profile so that their history output shows time stamps. Additionally I have changed their .history location to a dedicated... (9 Replies)
Discussion started by: hedkandi
9 Replies

6. Shell Programming and Scripting

Epoch & Unix Timestamp Conversion Tools

Hi All, Please read the below data carefully. I need an unix command for converting unix timestamp to Epoch timestamp. I need to daily convert this today's unix(UTC) time to epoch time, so i am thinking to make a shellscript for this. Please help me for this by providing... (3 Replies)
Discussion started by: aish11
3 Replies

7. Solaris

Covert Global zone to local zone

Dears, I would like to convert solaris 10 x86 and solaris 10 sparc (Global Zones) physical servers into Local zones. i found a document which seems to be helpful but i'm stuck @ the 1st step. to test this i want to do it 1st on x86 system running under vmware ESXi and if it succeeds i will... (1 Reply)
Discussion started by: mduweik
1 Replies

8. Shell Programming and Scripting

epoch conversion

I need to convert an epoch time from a file into a standard UTC time and output it in the same format but I'm not sure what's the best approach here's the input file and the bold part is what I need to convert. 1,1,"sys1",60,300000 2,"E:",286511144960 3,1251194521,"E:",0,0... (2 Replies)
Discussion started by: satchy321
2 Replies

9. Solaris

Not able to ping global zone from local zone

Hi Gurus I am not able to ping the local zone from global zone when i am trying to ping i am getting below ICMP Host Unreachable from gateway zone ( 192.268.35.210) for icmp from zone ( 192.168.35.210) to sun1 ( 192.168.35.210) However i can ping local zone from global please... (12 Replies)
Discussion started by: kumarmani
12 Replies
Login or Register to Ask a Question