note 80333 added to function.getdate
| From: | timforte at gmail dot com | Date: | Thu, 10 Jan 2008 16:07:45 +0000 |
| Subject: | note 80333 added to function.getdate | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-135002@lists.php.net to get a copy of this message | ||
It's worth noting that this is local time, not UTC/GMT - gmgetdate doesn't exist :(.
The most logical way to handle date arithmetic without hitting DST problems is to work in UTC...
function add_days($my_date,$numdays) {
$date_t = strtotime($my_date.' UTC');
return gmdate('Y-m-d',$date_t + ($numdays*86400));
}
[it's even faster if you use gmmktime instead of strtotime]
----
Server IP: 87.124.64.96
Probable Submitter: 213.208.117.249
----
Manual Page -- http://www.php.net/manual/en/function.getdate.php
Edit -- https://master.php.net/note/edit/80333
Del: integrated -- https://master.php.net/note/delete/80333/integrated
Del: useless -- https://master.php.net/note/delete/80333/useless
Del: bad code -- https://master.php.net/note/delete/80333/bad+code
Del: spam -- https://master.php.net/note/delete/80333/spam
Del: non-english -- https://master.php.net/note/delete/80333/non-english
Del: in docs -- https://master.php.net/note/delete/80333/in+docs
Del: other reasons-- https://master.php.net/note/delete/80333
Reject -- https://master.php.net/note/reject/80333
Search -- https://master.php.net/manage/user-notes.php