Page 1 of 1

UTC_TIMESTAMP

Posted: Thu Jul 21, 2011 7:46 pm
by supersonictt
Hello,

I have this in my blog php code:

Code: Select all

if ($_POST['submit']) 
   {
      $sql = "INSERT INTO blog_entries(category_id, dateposted, subject, body) VALUES(" . $_POST['category'] . ", NOW(), '" . fix_quotes($_POST['subject']) . "', '" . fix_quotes($_POST['body']) . "');";
      mysql_query($sql);
      header("Location: " . basename(__FILE__));
      exit;
   }
When someone posts a comment, it gives the time of the server in the states (+7 hours difference from my local time). What I did is to replace "NOW()" with "UTC_TIMESTAMP() + 030000". Everything worked right. BUT, if someone posts any comment after 9PM UTC time it shows the date wrong as the date is changed as well and this will show the whole time and date in a wrong format.

Is there a better solution for that? What I need is that the post is shown in the blog in the proper time and date.

I am not that good in PHP, I am using a WYSIWYG software to build up my site, and I learned some few stuff about PHP. This is the reason why I cannot figure it out!

Thanks a lot

Re: UTC_TIMESTAMP

Posted: Thu Jul 21, 2011 7:47 pm
by beetree
Likely error: You're displaying the time as it is in the server location. Rather adjust it to the browsers (=your) location. Browser timezone is not provided in the request headers, so you need to get it through a Javascript request.

Re: UTC_TIMESTAMP

Posted: Thu Jul 21, 2011 7:53 pm
by supersonictt
beetree wrote:Likely error: You're displaying the time as it is in the server location. Rather adjust it to the browsers (=your) location. Browser timezone is not provided in the request headers, so you need to get it through a Javascript request.
Thanks for the reply.

Is it possible to use "date_default_timezone_set(Asia/Amman); function?
If yes, what other things I need to include in the code to report the time properly?