Jump to content


Photo

how to use currentdate function but deduct an hour?


  • Please log in to reply
8 replies to this topic

#1 crypted

crypted
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 24 October 2006 - 06:25 AM

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.

#2 bob_the _builder

bob_the _builder
  • Members
  • PipPipPip
  • Advanced Member
  • 207 posts

Posted 24 October 2006 - 06:38 AM

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:

DATE_FORMAT(ADDDATE(date, INTERVAL 3 HOUR), '%d %b %Y %r') AS date

hth

#3 heckenschutze

heckenschutze
  • Members
  • PipPipPip
  • Advanced Member
  • 257 posts
  • LocationAustralia

Posted 24 October 2006 - 07:20 AM

If your using a unix timestamp,

<?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);
}
?>

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

hth.

#4 crypted

crypted
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 24 October 2006 - 07:22 AM

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.

#5 heckenschutze

heckenschutze
  • Members
  • PipPipPip
  • Advanced Member
  • 257 posts
  • LocationAustralia

Posted 24 October 2006 - 07:27 AM

.

#6 Zane

Zane
  • Administrators
  • Advanced Member
  • 4,134 posts

Posted 24 October 2006 - 07:28 AM

echo strtotime("-1 hour", strtotime(mosCurrentDate()));

btn_donate_SM.gif Want to thank me? Contribute to my PayPal piggy-bank
 

172938.png

#7 crypted

crypted
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 24 October 2006 - 04:05 PM

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>

#8 Zane

Zane
  • Administrators
  • Advanced Member
  • 4,134 posts

Posted 24 October 2006 - 08:16 PM

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
date("Y-m-d:h:m:s", strtotime("-1 hour", strtotime(mosCurrentDate())));

btn_donate_SM.gif Want to thank me? Contribute to my PayPal piggy-bank
 

172938.png

#9 crypted

crypted
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 24 October 2006 - 08:45 PM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users