note 40314 modified in function.mktime by danbrown
| From: | danbrown@php.net | Date: | Sun, 20 Jul 2008 03:38:52 +0000 |
| Subject: | note 40314 modified in function.mktime by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-142083@lists.php.net to get a copy of this message | ||
I find it easiest, if I want to find you how many days there are between two dates to use the
following method:
<?php
$init_day = 1;
$init_mth = 1;
$init_yr = 2004;
$dst_day = 5;
$dst_mth = 8;
$dst_yr = 2004;
//first convert to unix timestamp
$init_date = mktime(12,0,0,$init_mth,$init_day,$init_yr);
$dst_date = mktime(12,0,0,$init_mth,$init_day,$init_yr);
$offset = $dst_date-$init_date; //Depending on which offset type you want, switch order
$days = floor($offset/60/60/24);
?>
--was--
I find it easiest, if I want to find you how many days there are between two dates to use the
following method:
$init_day = 1;
$init_mth = 1;
$init_yr = 2004;
$dst_day = 5;
$dst_mth = 8;
$dst_yr = 2004;
//first convert to unix timestamp
$init_date = mktime(12,0,0,$init_mth,$init_day,$init_yr);
$dst_date = mktime(12,0,0,$init_mth,$init_day,$init_yr);
$offset = $dst_date-$init_date; //Depending on which offset type you want, switch order
$days = floor($offset/60/60/24);
http://php.net/manual/en/function.mktime.php