![]() |
|
|
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 |
| Calculate time to some date | Sapfeer | High Level Programming | 4 | 07-08-2009 11:10 AM |
| Calculate date by week | thans_guban | Shell Programming and Scripting | 2 | 10-28-2008 09:31 AM |
| calculate the date of next satureday of current date. | rinku | Shell Programming and Scripting | 3 | 09-03-2008 12:05 AM |
| How to Calculate weekly date range | mamta | UNIX for Dummies Questions & Answers | 1 | 03-06-2008 06:50 AM |
| How can I use mathematic calculate in date? | guitaroa47 | Shell Programming and Scripting | 1 | 06-05-2007 08:37 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
date duration fail to calculate
Hi Everyone, I was very sad after a long way but still cannot figure out the duration between two date. Code:
$date1="20090812 23:48:56"; $date2="20090813 00:01:37"; The output will be "001241". I did the following tries, like print localtime(UnixDate(ParseDate("20090812 23:48:56"),"%s")); and other ways to calculate the differience, but :--( Please advice. Thanks
|
|
|||||
|
A quick search produced: Yesterdays Date/Date Arithmetic
|
|
||||
|
Below is the finally code, hope this is the most simple method. i have two date, i want to get the duration in to hhmmss format. Below is the working code. Code:
$a = localtime(UnixDate(ParseDate("20090823 08:03:35"),"%s"));
$b = localtime(UnixDate(ParseDate("20090823 12:04:55"),"%s"));
$c = str2time($b)-str2time($a);
$hms=sprintf("%02d%02d%02d",int($c/3600),int($c%3600/60),int($c%60));
print $hms;
![]() |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|