Help on awk strftime


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help on awk strftime
# 1  
Old 12-08-2013
Help on awk strftime

cat file

Code:
41285.000034722223 41285.000567129631
41285.000069444446 41285.001122685186
41285.000092592592 41285.001620370371
41285.000138888892 41285.00340277778
41285.000185185185 41285.000405092593
41285.000196759262 41285.000856481478
41285.000208333331 41285.000717592593
41285.000300925924 41285.001319444447
41285.000451388885 41285.000590277778
41285.000486111108 41285.002430555556
41285.000532407408 41285.000902777778
41285.000567129631 41285.00099537037
41285.000659722224 41285.001608796294
41285.000763888886 41285.001319444447
41285.000775462962 41285.000856481478
41285.000787037039 41285.001469907409


it should be
Code:
1/11/13 12:00 AM    1/11/13 12:00 AM
1/11/13 12:00 AM    1/11/13 12:01 AM
1/11/13 12:00 AM    1/11/13 12:02 AM
1/11/13 12:00 AM    1/11/13 12:04 AM
1/11/13 12:00 AM    1/11/13 12:00 AM
1/11/13 12:00 AM    1/11/13 12:01 AM
1/11/13 12:00 AM    1/11/13 12:01 AM
1/11/13 12:00 AM    1/11/13 12:01 AM
1/11/13 12:00 AM    1/11/13 12:00 AM
1/11/13 12:00 AM    1/11/13 12:03 AM
1/11/13 12:00 AM    1/11/13 12:01 AM
1/11/13 12:00 AM    1/11/13 12:01 AM
1/11/13 12:00 AM    1/11/13 12:02 AM
1/11/13 12:01 AM    1/11/13 12:01 AM
1/11/13 12:01 AM    1/11/13 12:01 AM
1/11/13 12:01 AM    1/11/13 12:02 AM


i used
awk '{$1=$2=strftime("%c",$1)} {print}' file
Code:
Thu 01 Jan 1970 02:28:05 PM AST Thu 01 Jan 1970 02:28:05 PM AST
Thu 01 Jan 1970 02:28:05 PM AST Thu 01 Jan 1970 02:28:05 PM AST
Thu 01 Jan 1970 02:28:05 PM AST Thu 01 Jan 1970 02:28:05 PM AST
Thu 01 Jan 1970 02:28:05 PM AST Thu 01 Jan 1970 02:28:05 PM AST
Thu 01 Jan 1970 02:28:05 PM AST Thu 01 Jan 1970 02:28:05 PM AST
Thu 01 Jan 1970 02:28:05 PM AST Thu 01 Jan 1970 02:28:05 PM AST
Thu 01 Jan 1970 02:28:05 PM AST Thu 01 Jan 1970 02:28:05 PM AST
Thu 01 Jan 1970 02:28:05 PM AST Thu 01 Jan 1970 02:28:05 PM AST
Thu 01 Jan 1970 02:28:05 PM AST Thu 01 Jan 1970 02:28:05 PM AST
Thu 01 Jan 1970 02:28:05 PM AST Thu 01 Jan 1970 02:28:05 PM AST
Thu 01 Jan 1970 02:28:05 PM AST Thu 01 Jan 1970 02:28:05 PM AST
Thu 01 Jan 1970 02:28:05 PM AST Thu 01 Jan 1970 02:28:05 PM AST
Thu 01 Jan 1970 02:28:05 PM AST Thu 01 Jan 1970 02:28:05 PM AST
Thu 01 Jan 1970 02:28:05 PM AST Thu 01 Jan 1970 02:28:05 PM AST
Thu 01 Jan 1970 02:28:05 PM AST Thu 01 Jan 1970 02:28:05 PM AST
Thu 01 Jan 1970 02:28:05 PM AST Thu 01 Jan 1970 02:28:05 PM AST

# 2  
Old 12-08-2013
What does this number signify - 41285.000034722223 ?
# 3  
Old 12-08-2013
hi,

you need to give awk the date you want to output
Code:
awk 'BEGIN{s=41285.001469907409; d=mktime("2013 11 1 0 0 0");print strftime("%F - %T",d+s)}'
2013-11-01 - 11:28:05

# 4  
Old 12-08-2013
I guess that numbers are windows 1900 times? Not sure how to translate in unix unless you can give us 01/01/1970 in windows 1900 time.
# 5  
Old 12-09-2013
Try this:

Code:
TZ=GMT awk '{
   print strftime("%m/%d/%y %I:%M %p", (($1 - 25569 ) * 3600 * 24)),
         strftime("%m/%d/%y %I:%M %p", (($2 - 25569 ) * 3600 * 24)) }' OFS='\t' infile

This User Gave Thanks to Chubler_XL For This Post:
# 6  
Old 12-09-2013
many thanks to Chubler_XL
SOLVED
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Combining awk printf and print strftime command

I have a lines like below, captured from rrdtool fetch command, 1395295200 2.0629986254e+06 7.4634784967e+05 1395297000 2.0198121616e+06 6.8658888903e+05 1395298800 1.8787141122e+06 6.7482866452e+05 1395300600 1.7586118678e+06 6.7867977653e+05 1395302400 1.8222762151e+06 7.1301678859e+05I'm... (3 Replies)
Discussion started by: rk4k
3 Replies

2. Shell Programming and Scripting

awk mktime(strftime(format,"6-FEB-2013 08:50:03.841")

I'm trying to use AWK to filter on some dates in a field by converting them to Unix Time. mktime(strftime(format,"6-FEB-2013 08:50:03.841")What is the proper format for my date strings as they appear in my database? My first thought is %d-%b-%Y %H:%M:%Sbut I see the following issues: %d is... (3 Replies)
Discussion started by: Michael Stora
3 Replies

3. UNIX for Advanced & Expert Users

[SOLVED] Making mktime/strftime available to mawk

I frequently use awk time functions and am switching some scripts over to mawk. I don't have the mktime or strftime functions in mawk, but it appears that there is a way, as explained here in "Time functions": Please only cut-and-past links to man pages from our man pages. So, simple... (10 Replies)
Discussion started by: treesloth
10 Replies

4. Programming

strftime equivalent in c++

HI, i wish to convert a millsec value to a readable string format. the one option is to use strftime. However this is a bit costly (1-5 micros). is there a a faster way to do so with just string manipulation (Note i have the date object which has the time details but wish o avoid strftime) (2 Replies)
Discussion started by: wojtyla
2 Replies

5. Programming

strftime() creates memory leak

Hi, I am facing one strange situation while using strftime() to get current date and time in C. it leaks memory with %T strftime(L_StrDate,30,"%d-%b-%C%y %T", localtime((time_t *)&tv.tv_sec)) ; and when i use another option then no memory leak like strftime(L_StrDate,30,"%d-%b-%C%y ... (3 Replies)
Discussion started by: apskaushik
3 Replies

6. Shell Programming and Scripting

perl replace awk strftime

Hi Everyone i have a perl file below, one of the line is convert the pcho time to human readable format. $value=`awk 'BEGIN{print strftime("%c",1273236600)}' | tr -d '\n'`; if image, if i have lots of pcho time value in a file, if i use this awk, strftime, then tr -d to remove the \n,... (2 Replies)
Discussion started by: jimmy_y
2 Replies

7. Shell Programming and Scripting

gawk and strftime()

Strange behaviour of the strftime() function from gawk (3.1.5): $ awk 'BEGIN{print strftime("%T", 3600)}' > 02:00:00 $ awk 'BEGIN{print strftime("%T", 0)}' > 01:00:00 Obviously something with DST but I can not figure out why? To me 3600 epoch seconds remains 01:00, DST or not. From... (2 Replies)
Discussion started by: ripat
2 Replies
Login or Register to Ask a Question