note 78077 added to function.mktime

From: Date: Thu, 27 Sep 2007 03:33:00 +0000
Subject: note 78077 added to function.mktime
Groups: php.notes 
Request: Send a blank email to php-notes+get-130818@lists.php.net to get a copy of this message
I've been using the mktime() function to calculate difference between dates. It works fine to me until I need to do calculation in more wide dates, like 01/01/2070. There will be a huge problem to all those that use timestamps to calculate dates after 2038-01-19T03:14:08+0000Z (like posted by PHPCoder). I got a code from "google" (thanx to Amrit Hallan) that can successfully calculate the difference *in days* between two dates. <?php function dateDiff($dformat, $endDate, $beginDate) { $date_parts1=explode($dformat, $beginDate); $date_parts2=explode($dformat, $endDate); $start_date=gregoriantojd($date_parts1[0], $date_parts1[1], $date_parts1[2]); $end_date=gregoriantojd($date_parts2[0], $date_parts2[1], $date_parts2[2]); return $end_date - $start_date; } ?> You can use it like these: <?php echo dateDiff("/", "01/31/2070", "01/31/2000"); ?> It should returns 25568 (days between). I wish that help. ---- Server IP: 69.147.83.197 Probable Submitter: 201.86.3.72 ---- Manual Page -- http://www.php.net/manual/en/function.mktime.php Edit -- https://master.php.net/note/edit/78077 Del: integrated -- https://master.php.net/note/delete/78077/integrated Del: useless -- https://master.php.net/note/delete/78077/useless Del: bad code -- https://master.php.net/note/delete/78077/bad+code Del: spam -- https://master.php.net/note/delete/78077/spam Del: non-english -- https://master.php.net/note/delete/78077/non-english Del: in docs -- https://master.php.net/note/delete/78077/in+docs Del: other reasons-- https://master.php.net/note/delete/78077 Reject -- https://master.php.net/note/reject/78077 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#130818) next »