|  |  | 
| EnderUNIX İpucuArkadaşıma gönder , Ana Sayfa[ UNIX ] "Tarihi(date) timestamp e cevirmek" - Huzeyfe Önal - (2004-12-02 14:36:51) [3440] $date Thu Dec 2 13:56:00 EET 2004 bu komutun ciktisini timestamp formatina cevirmek icin asagidaki perl scriptini kullanabilirsiniz . ##############cevir.pl###### #!/usr/bin/perl use POSIX; my ( $wday, $year, $month, $date, $time, $zone, @wdays, @months, ); @months = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); $inputDate = @words = split (/\s+/, $inputDate); $wday = $words[0]; $month = $words[1]; $date = $words[2]; $time = $words[3]; $zone = $words[4]; $year = $words[5]; print "\ndate commands output:\n" . "~~~~~~~~~~~~~~~~~~~~~\n\t\t$inputDate\n"; for($i = 0; $i <= $#wdays; $i++) { if ("$wday" eq "$wdays[$i]") { $wday = $i; last; } } for($i = 0; $i <= $#months; $i++) { if ("$month" eq "$months[$i]") { $month = $i; last; } } @time_components = split (/\:/, $time); $hour = $time_components[0]; $min = $time_components[1]; $sec = $time_components[2]; $year = $year - 1900; print "arguments to the mktime() method:\n" . "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n"; print "sec = $sec, min = $min, hour = $hour,\ndate = $date, month = $month, " . "year (this yr. - 1900) = $year, day = $wday \n\n"; $timestamp = mktime($sec, $min, $hour, $date, $month, $year, $wday, 0, -1); print "********************************\n"; print "CALCULATED TIMESTAMP = "; print "$timestamp \n"; print "********************************\n"; print "PRESENT TIMESTAMP = "; print (time()); print "\n"; print "********************************\n\n"; ##########cevir.pl########## $chmod +x cevir.pl diretk date komutunun ciktisini cevir.pl'e parametre olarak verebiliriz. $date |./cevir.pl date commands output: ~~~~~~~~~~~~~~~~~~~~~ Thu Dec 2 14:35:51 EET 2004 arguments to the mktime() method: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sec = 51, min = 35, hour = 14, date = 2, month = 11, year (this yr. - 1900) = 104, day = Thu ******************************** CALCULATED TIMESTAMP = 1101990951 ******************************** PRESENT TIMESTAMP = 1101990951 ******************************** ihtiyaca gore awk,cut vb gibi programciklarla bezenerek isteginize gore ayarlanabilir.. not::perl scripti bana ait degil Arkadaşıma gönder , Ana Sayfa |  |