note 72412 deleted from function.date by tularis

From: Date: Thu, 09 Feb 2012 21:02:59 +0000
Subject: note 72412 deleted from function.date by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-186019@lists.php.net to get a copy of this message
Note Submitter: code at ashleyhunt dot co dot uk ---- I wanted to shift an sql date forward by a set time period. This is how I achived it... well handy. <?php function sql_date_shift($date, $shift) { return date("Y-m-d H:i:s" , strtotime($shift, strtotime($date))); } // example usage $date = "2006-12-31 21:00"; $shift "+6 hours"; // could be days, weeks... see function strtotime() for usage echo sql_date_shift($date, $shift); // will output: 2007-01-01 03:00:00 ?> Hope it is of use, Ashley

« previous php.notes (#186019) next »