UTC_TIMESTAMP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
supersonictt
Forum Newbie
Posts: 9
Joined: Mon Jul 11, 2011 7:08 pm

UTC_TIMESTAMP

Post 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
beetree
Forum Commoner
Posts: 26
Joined: Mon Jul 18, 2011 6:30 pm
Location: Peninsula

Re: UTC_TIMESTAMP

Post 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.
supersonictt
Forum Newbie
Posts: 9
Joined: Mon Jul 11, 2011 7:08 pm

Re: UTC_TIMESTAMP

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