Jump to content

Archived

This topic is now archived and is closed to further replies.

crypted

how to use currentdate function but deduct an hour?

Recommended Posts

I have a website that's obviously hosted on an EST timezone machine.  Our website is time-based with quite a number of features, but we are in CST.  This is an hour less than, or an hour behind, the server the website resides on.  Is there a way to have <?php echo mosCurrentDate(); ?> modified so that it will have an hour less, or the correct current date and time of the CST timezone instead of the EST timezone?  Thanks so much for all input.

Share this post


Link to post
Share on other sites
Hi,

Prolly not the answer you after .. But I alter the date in my query when I call it from the database to display on the page:

[code=php:0]DATE_FORMAT(ADDDATE(date, INTERVAL 3 HOUR), '%d %b %Y %r') AS date[/code]

hth

Share this post


Link to post
Share on other sites
If your using a unix timestamp,

[code]<?php
//** from php manual, not mine. Since we made need negative bases
function npow($base, $exp)
{
  $result = pow(abs($base), $exp);
  if ($exp % 2 !== 0) {
      $result = - ($result);
  }
  return $result;
}

function ModifyTimeStamp($timestamp, $hours, $minutes, $seconds)
{
return ($timestamp + npow($hours, 3) + npow($minutes, 2) + $seconds);
}
?>[/code]

, else show us the code your using to display/calculate the date.

hth.

Share this post


Link to post
Share on other sites
I'm using <?php echo mosCurrentDate(); ?> to display the time, and I believe it's basically using the FreeBSD servers time to call and echo through php onto the website.

Share this post


Link to post
Share on other sites
the output for "echo strtotime("-1 hour", strtotime(mosCurrentDate()));" gives 1161695160 instead of a time/date...  not sure why?

<td valign="top"><div align="left" class="date"><?php echo strtotime("-1 hour", strtotime(mosCurrentDate())); ?></div></td>

Share this post


Link to post
Share on other sites
what's the way the date should correctly show.

take a look at the date funciton here http://www.php.net/date

and use this whole statement as the second argument
for instance
[code=php:0]
date("Y-m-d:h:m:s", strtotime("-1 hour", strtotime(mosCurrentDate())));
[/code]

Share this post


Link to post
Share on other sites
I follow what you're saying, but when I implement that string, it outputs the correct date, 2006-10-24, but the time gets output as 01:10:00 when the system time is 4:42PM and the CST time is 3:42PM...

Share this post


Link to post
Share on other sites

×

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.