Mysql Date functions in php code

in mysql, PHP Code / No Comments

Hello friends,

The following query will add some times to mysql date column.

Get the today date :

$date = date(‘Y-m-d H:i:s’);

Convert it into strtotime and add which one we have to add, here i am going to add 30 minutes to existing time.

$newtime = strtotime($date . ‘ + 30 minutes’);

Covert the newtime to date format like below.

$newtime = date(‘Y-m-d H:i:s’, $newtime);

Here we will get the answer , same thing we can apply for mysql datetime column field also.

With more than 9 years experience in PHP and Founder of Anil Labs, a blog for PHP and related posts. contributed posts regarding CodeIgniter, CakePHP and Learn PHP online ... Contact : php.anil@gmail.com

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>