converting epoch time to ddmmyy format


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting converting epoch time to ddmmyy format
# 1  
Old 01-24-2012
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
# 2  
Old 01-24-2012
Code:
date -d @1327329935 +%d%m%y

# 3  
Old 01-24-2012
date -d does not work on Solaris
Code:
$ date -d @1327329935 +%d%m%y
date: illegal option -- d
usage:  date [-u] mmddHHMM[[cc]yy][.SS]
        date [-u] [+format]
        date -a [-]sss[.fff]


Last edited by Franklin52; 01-24-2012 at 11:00 AM.. Reason: Please use code tags for code and data samples, thank you
# 4  
Old 01-24-2012
Code:
perl -MPOSIX -le 'print strftime ("%d%m%y", localtime (1327329935))'

# 5  
Old 01-24-2012
Thanks a lot !
that worked perfectly .

---------- Post updated at 10:34 AM ---------- Previous update was at 10:15 AM ----------

now iam stuck again !
perl is not translating the variable . without variable it gives me the correct date value but if i try to use a variable its giving me wrong values.
Code:
sdcprd@dotstoas110:$ echo $F2
1327332411
sdcprd@dotstoas110:$ perl -MPOSIX -le 'print strftime ("%m%d%y",localtime (1327332411))'
012312
sdcprd@dotstoas110:$ perl -MPOSIX -le 'print strftime ("%m%d%y",localtime ($F2))'
123169
sdcprd@dotstoas110:$ perl -MPOSIX -le 'print strftime ("%m%d%y",localtime (${F2}))'
123169

---------- Post updated at 10:35 AM ---------- Previous update was at 10:34 AM ----------

now iam stuck again !
perl is not translating the variable . without variable it gives me the correct date value but if i try to use a variable its giving me wrong values.

Code:
sdcprd@dotstoas110:$ echo $F2
1327332411
sdcprd@dotstoas110:$ perl -MPOSIX -le 'print strftime ("%m%d%y",localtime (1327332411))'
012312
sdcprd@dotstoas110:$ perl -MPOSIX -le 'print strftime ("%m%d%y",localtime ($F2))'
123169
sdcprd@dotstoas110:$ perl -MPOSIX -le 'print strftime ("%m%d%y",localtime (${F2}))'
123169


Last edited by Franklin52; 01-25-2012 at 03:56 AM.. Reason: Please use code tags for code and data samples, thank you
# 6  
Old 01-24-2012
Code:
perl -MPOSIX -le 'print strftime ("%m%d%y",localtime ('$F2'))'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

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

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

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 real time to epoch time

# date +%s -d "Mon Feb 11 02:26:04" 1360567564 # 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 1359453135154 rather than 10 digit epoch time 1360567564... (3 Replies)
Discussion started by: vivek d r
3 Replies

5. Shell Programming and Scripting

Using awk or nawk to convert epoch time to date format

Looking for some help and usually when I do a search this site comes up. Hopefully someone can give me a little direction as to how to use one of these two commands to achieve what I'm trying to do. What am I trying to do? I need to take the time value in epoch format returned from the... (5 Replies)
Discussion started by: minigts
5 Replies

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

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

8. UNIX for Dummies Questions & Answers

getting the current time in Epoch format

Hi everybody, I want to get the current time in epoch format (in UNIX or Korn Shell) and store it in a variable called currentTime. Any response will be highly appreciated:) Thanks in advance, omoyne:D (8 Replies)
Discussion started by: omoyne
8 Replies

9. Shell Programming and Scripting

Convert Epoch time format to normal date time format in the same file

I have a file named "suspected" with series of line like these : {'protocol': 17, 'service': 'BitTorrent KRPC', 'server': '219.78.120.166', 'client_port': 52044, 'client': '10.64.68.44', 'server_port': 8291, 'time': 1226506312L, 'serverhostname': ''} {'protocol': 17, 'service': 'BitTorrent... (3 Replies)
Discussion started by: rk4k
3 Replies

10. 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
Login or Register to Ask a Question