Converting real time to epoch time


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Converting real time to epoch time
# 1  
Old 02-11-2013
Converting real time to epoch time

Code:
[root@ds-accm-z2-pri196 ~]# date +%s -d "Mon Feb 11 02:26:04"
1360567564
[root@ds-accm-z2-pri196 ~]# perl -e 'print scalar localtime(1360567564), "\n";'
Mon Feb 11 02:26:04 2013

the epoch conversion is working fine. but one of my application needs 13 digit epoch time as input
Code:
1359453135154

rather than 10 digit epoch time
Code:
1360567564

is there some conversion that i am missing? any help will be deeply appreciated. thanks

PS: in one of the epoch online conversion website i tried to convert both types of epoch time. both are working but in unix i am not able to convert into 13 digit output epoch time :-(

Code:

# 2  
Old 02-11-2013
epoch 13 uses milliseconds instead of seconds, since you are not using the extra precision with your date command, why not try simply adding 3 zeroes at the end?
Code:
date +%s000 -d "Mon Feb 11 02:26:04"


Last edited by Scrutinizer; 02-11-2013 at 04:34 AM..
This User Gave Thanks to Scrutinizer For This Post:
# 3  
Old 02-11-2013
thanks mate it worked with my application :-)
# 4  
Old 03-27-2013
Hi all,
Can any1 suggest me how can i get the epoch time of file.
i mean...
ls -l test.txt | awk '{print $6,""$7,""$8}' gives me Nov 30 2011...
now is there any way i can convert this into epoch time for this particular file only...
Thanks

Last edited by radoulov; 03-27-2013 at 06:20 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Awk: time intervals based on epoch time

I have a list of epoch times delimited by "-" as follows: 1335078000 - 1335176700 1335340800 - 1335527400 1335771300 - 1335945600 1336201200 - 1336218000 The corresponding dates are: 20120422 1000 - 20120423 1325 20120425 1100 - 20120427 1450 20120430 1035 - 20120502 1100 ... (3 Replies)
Discussion started by: alex2005
3 Replies

2. Shell Programming and Scripting

Converting a random epoch time into a readable format

I am trying to create a script that will take epoch (input from command line) and convert it into a readable format in bash/shell ---------- Post updated at 08:03 PM ---------- Previous update was at 07:59 PM ---------- #!bin/bash read -p "Please enter a number to represent epoch time:"... (9 Replies)
Discussion started by: sprocket
9 Replies

3. UNIX for Dummies Questions & Answers

Converting Epoch time

I have a Raspberry Pi that logs some temperatures using Onewire. Data is collected with RRDTool. The command sudo rrdtool fetch ute_temp.rrd AVERAGE -s -1h > ./test.log and then cat test.log gives the result 1388608500: 2.3579639836e+00 . How do I write a script that converts the Epoch time... (4 Replies)
Discussion started by: nilekl
4 Replies

4. Shell Programming and Scripting

converting epoch time to ddmmyy format

I can not find a working script or way to do this on sun solaris , can someone please guide me? e.g 1327329935 epoch secs = 012312 (ddmmyy) thanks (5 Replies)
Discussion started by: aliyesami
5 Replies

5. Programming

Converting a user inputted date to epoch time

Hi all , I need to know how to convert a time stamp entered by the user to be converted to GMT/UTC(epoch time) using mktime() and gmtime() for exapample the input will be put in the form ptm.tm_sec = 0; ptm.tm_min = 59; ptm.tm_hour = 11; ptm.tm_mday = 20;... (2 Replies)
Discussion started by: ada
2 Replies

6. Shell Programming and Scripting

converting epoch time

Hi, Thanks bartus11 yesterday's code worked fine for me. In meantime I've found another "issue". As you can see highlighted, the time format in my original input in case of two rows which should be duplicited ,is differentwhat I need to do is to convert to this format "20110607-08:03:22"... (4 Replies)
Discussion started by: hernand
4 Replies

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

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

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

10. UNIX for Advanced & Expert Users

EPOCH to real time?

hi all :confused: i am wondering if there is a way to convert from EPOCH time to the standard tim, may be using a script or some thing else??????? thanks............................ (5 Replies)
Discussion started by: TheEngineer
5 Replies
Login or Register to Ask a Question