List Info

Thread: note 78077 added to function.mktime




note 78077 added to function.mktime
user name
2007-09-26 22:33:00
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  -- h
ttps://master.php.net/note/delete/78077/integrated
Del: useless     -- http
s://master.php.net/note/delete/78077/useless
Del: bad code    -- htt
ps://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     -- http
s://master.php.net/note/delete/78077/in+docs
Del: other reasons-- https://mast
er.php.net/note/delete/78077
Reject      -- https://mast
er.php.net/note/reject/78077
Search      -- https://
master.php.net/manage/user-notes.php

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php


note 78077 deleted from function.mktime by bjori
user name
2007-09-27 07:29:08
Note Submitter: Carlos Pauluk carloseduardopaulukgmail
Reason: useless

----

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.

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )