note 80333 deleted from function.getdate by salathe

From: Date: Mon, 21 Sep 2020 14:32:22 +0000
Subject: note 80333 deleted from function.getdate by salathe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-215191@lists.php.net to get a copy of this message
Note Submitter: timforte at gmail dot com ---- 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]

« previous php.notes (#215191) next »