vinpkl Posted February 10, 2009 Share Posted February 10, 2009 hi all my website is running in new zealand and hosting is also in newzealand. To insert the date i m using <?php $product_date=date("Y/m/d"); ?> So as result the date that gets inserted in database is of one day earlier. like at present its 11feb in newzealand and the date that gets inserted in the database is 10feb. how can i get the current date of newzealand in my database. vineet Quote Link to comment https://forums.phpfreaks.com/topic/144621-getting-one-day-back-mysql-date/ Share on other sites More sharing options...
printf Posted February 10, 2009 Share Posted February 10, 2009 Use gmdate() instead... <?php $product_date = gmdate ( 'Y/m/d' ); ?> Quote Link to comment https://forums.phpfreaks.com/topic/144621-getting-one-day-back-mysql-date/#findComment-758891 Share on other sites More sharing options...
vinpkl Posted February 10, 2009 Author Share Posted February 10, 2009 Use gmdate() instead... <?php $product_date = gmdate ( 'Y/m/d' ); ?> hi printf i used the gmdate() but still getting the one day old date. i would like to ask that my website is running in new zealand but at present i m in india and if i insert any product from india then the date inserted in database will be according to india or newzealand. actually the website is to run only in newzealand so i need to have the date as of present date of newzealand. vineet Quote Link to comment https://forums.phpfreaks.com/topic/144621-getting-one-day-back-mysql-date/#findComment-758896 Share on other sites More sharing options...
php.ajax.coder Posted February 10, 2009 Share Posted February 10, 2009 <?PHP $timestamp = mktime(0,0,0,date('n'),date('j')-1,'date('Y')); $product_date = date('Y/m/d',$timestamp); ?> mktime() - http://uk.php.net/manual/en/function.mktime.php date() - http://uk.php.net/manual/en/function.date.php Quote Link to comment https://forums.phpfreaks.com/topic/144621-getting-one-day-back-mysql-date/#findComment-759023 Share on other sites More sharing options...
aschk Posted February 12, 2009 Share Posted February 12, 2009 This probably sounds silly, but when you posted this question, the date was the 10th of Feb... TODAY IS the 10th of Feb... Quote Link to comment https://forums.phpfreaks.com/topic/144621-getting-one-day-back-mysql-date/#findComment-760405 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.