note 80333 modified in function.getdate by danbrown

From: Date: Sun, 20 Jul 2008 03:05:05 +0000
Subject: note 80333 modified in function.getdate by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-142020@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... <?php 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] --was-- 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] http://php.net/manual/en/function.getdate.php

« previous php.notes (#142020) next »