Re: date

From: Date: Sun, 11 Mar 2001 19:16:26 +0000
Subject: Re: date
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-43404@lists.php.net to get a copy of this message
On 11 Mar 2001 10:25:25 -0800, FredrikAT <ftakle@online.no> wrote: >I have 2 dates... >$start = "20010101"; >$end = "20010312"; Use mktime() (http://www.php.net/manual/en/function.mktime.php) on those strings to convert them into Unix timestamps: $start_time = mktime(0,0,0, substr($start, 6, 2), substr($start, 4, 2), substr($start, 0, 4) ); // mktime( hour, minute, second, day, month, year) Since a Unix timestamp is just the number of seconds since a starting point, you can get the elapsed number of seconds by substraing $start_time from $stop_time; divide that by 86400 and you'll have the number of days. You could also use the Calendar extension if you have that installed, since it allows you to covert from several calendar systems into Julian Day counts, which could be subtracted similarly. (See http://www.php.net/manual/en/ref.calendar.php)

« previous php.general (#43404) next »