Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/144621-getting-one-day-back-mysql-date/
Share on other sites

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

<?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

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.