Convert value stored in a variable to epoch time?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Convert value stored in a variable to epoch time?
# 1  
Old 04-20-2010
Question Convert value stored in a variable to epoch time?

Hello

I have a the creation date of a file stored in a variable in the following format:
Code:
Wed May 06 10:14:58 2009

Is there a way I can echo the variable and display it in epoch time?

I've done a lot of searching on this topic, but haven't managed to get a solution. I'm on Solaris 10.

Thanks
Glyn
# 2  
Old 04-20-2010
1. do you have perl?
2. is getting the mtime directly from the file an option? - rather than what you have
-- in other words before creating your variable.
# 3  
Old 04-20-2010
what gives ?
Code:
date -d "Wed May 06 10:14:58 2009" +%s

Smilie OOPS : non GNU date !! Apologizes Smilie
Can't i remove my stupid post ?

Last edited by frans; 04-20-2010 at 11:26 AM.. Reason: OOPS !! Solaris : not GNU date
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert a string to epoch time

Team, I am working on a shell script and i am extracting a date string in "SunOS server" with below format. Mon Jan 21 04:13:48 EST 2021 Can you please assist me the best way to convert the extracted string to epoch time like "date +%s" in Linux. Thanks in advance (1 Reply)
Discussion started by: Girish19
1 Replies

2. Shell Programming and Scripting

Convert a date stored in a variable to epoch date

I am not able to pass date stored in a variable as an argument to date command. I get current date value for from_date and to_date #!/usr/bin/ksh set -x for s in server ; do ssh -T $s <<-EOF from_date="12-Jan-2015 12:02:09" to_date="24-Jan-2015 13:02:09" echo \$from_date echo... (7 Replies)
Discussion started by: raj48
7 Replies

3. Shell Programming and Scripting

Convert epoch time stamp into human readable format

Can someone help me to write a shell script to convert epoch timestamp into human readable format 1394553600,"test","79799776.0","19073982.728571","77547576.0","18835699.285714" 1394553600,"test1","80156064.0","19191275.014286","62475360.000000","14200554.720000"... (10 Replies)
Discussion started by: Moon1234
10 Replies

4. Shell Programming and Scripting

Convert epoch time to Julian date

Need assistance in converting an epoch time to Julian date To get epoch perl -e 'use Time::Local; print timelocal(1,5,2,12,10,2008), "\n"' (3 Replies)
Discussion started by: ajayram_arya
3 Replies

5. Shell Programming and Scripting

Convert to epoch time

how can i modify the following command to instead provide the epoch time of the interfaces file? perl -le 'print scalar localtime ((stat "/home/skysmart/interfaces"))' Tue Feb 19 03:44:52 2013 i'm hoping to get the equivalent of this command: stat --format=%Y /home/skysmart/interfaces ... (2 Replies)
Discussion started by: SkySmart
2 Replies

6. Shell Programming and Scripting

Shell script to convert epoch time to real time

Dear experts, I have an epoch time input file such as : - 1302451209564 1302483698948 1302485231072 1302490805383 1302519244700 1302492787481 1302505299145 1302506557022 1302532112140 1302501033105 1302511536485 1302512669550 I need the epoch time above to be converted into real... (4 Replies)
Discussion started by: aismann
4 Replies

7. Shell Programming and Scripting

how to convert date time to epoch time in solaris

Hi, Is there any easy way to convert date time(stored in shell variable ) to epoch time in solaris box? As +%s is working on linux but not on solaris, also -d option is not working. Any suggestion please? (6 Replies)
Discussion started by: anshuman0507
6 Replies

8. Shell Programming and Scripting

Convert Epoch Time to Standard Date and Time & Vice Versa

Hi guys, I know that this topic has been discuss numerous times, and I have search the net and this forum for it. However, non able to address the problem I faced so far. I am on Solaris Platform and unable to install additional packages like the GNU date and gawk to make use of their... (5 Replies)
Discussion started by: DrivesMeCrazy
5 Replies

9. Shell Programming and Scripting

how to convert epoch time to readible format?

Hi, I would like to convert epoch time from the logs to readible fromat. How do I do it within shell? Thanks! (11 Replies)
Discussion started by: cin2000
11 Replies

10. Shell Programming and Scripting

Convert from standard epoch time from a shell script?

Is there an easy method to do an on the fly conversion of a standard epoch time (seconds from 1970) to more readable date format? Does Unix have anything built in to do this? (4 Replies)
Discussion started by: LordJezo
4 Replies
Login or Register to Ask a Question