![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Date Conversion | jgrant746 | Shell Programming and Scripting | 3 | 05-24-2008 02:16 PM |
| Date Conversion | MJDRM | UNIX for Dummies Questions & Answers | 5 | 01-29-2008 06:20 PM |
| date conversion | tonet | Shell Programming and Scripting | 2 | 07-07-2006 10:23 AM |
| Date Conversion | dafidak | UNIX for Advanced & Expert Users | 2 | 07-04-2006 05:16 PM |
| date conversion | sunil bajaj | UNIX for Dummies Questions & Answers | 3 | 04-17-2002 01:54 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread |
Rating:
|
Display Modes |
|
|
|
|||||
|
Code:
BEGIN {
monN=split("JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC", months)
for(i=1; i<=monN; i++) {
months[months[i]]=i;
delete months[i];
}
}
function conv2mil(time, tA, tAnum, pm_am) {
tAnum=split(time, tA, ":")
sec=substr(tA[tAnum], 1, length(tA[tAnum])-2)
pm_am=toupper(substr(tA[tAnum], length(tA[tAnum])-1))
hour= (pm_am ~ /^P./) ? tA[1] + 12 : tA[1]
return (hour ":" tA[2] ":" sec)
}
{ printf("%s/%02d/%s %s\n", $3, months[toupper($1)], $2, conv2mil($4) ) }
|
|
||||
|
Quote:
Hi vgersh99 - hope you're still here i saw this thread and it really helped me a lot! however i'm having difficulty now figuring out how to convert this date format (May 5 13:01) to yyyymmddhhmm appending the current year (2009).for sample: (May 5 13:01) will be transformed to 200905051301 the reason i want to have it this way is in order for me to take the time difference of two variables. I've tried modifying your script by using sprintf, but i failed to make it work ![]() Hope you can help me with this ![]() Many thanks! |
![]() |
| Bookmarks |
| Tags |
| linux, ubuntu |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|