date() function

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
ibolui
Forum Commoner
Posts: 27
Joined: Thu May 26, 2005 9:41 am

date() function

Post by ibolui »

hi, i am having a problem with the date() as well as getdate().
the unix timestamp is 1117583940, which should be converted to 31 may 2005.
but i use both date() and getdate() and they give me 1 june 2005.

someone helps? thanks.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

Yep, I'm getting "Tuesday, May 31st, 2005 - 5:59 pm" from that stamp. Can you show your code?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
ibolui
Forum Commoner
Posts: 27
Joined: Thu May 26, 2005 9:41 am

Post by ibolui »

hmm.. here's my code

$date = date("d F Y", $row['date']);
where $row['date'] is the timestamp

i am using php 5.0.4 in winxp...
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

Well, if when you echo $date and $row['date'] right after that, you get 1117583940 and 1 june 2005 respectively, I have no idea. Maybe try putting the time of day in $date as well to see exactly how much its off.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
ibolui
Forum Commoner
Posts: 27
Joined: Thu May 26, 2005 9:41 am

Post by ibolui »

i tried

Code: Select all

date(&quote;r&quote;, $rowї'date'])
and get wed 01 jun 2005 07:59:00 +0800
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

Could it be timezone problems? Like I said, I'm getting 5:59 PM, in MST which is -0700 right now. With the time difference, that would pop it ahead a day. I'm not really sure how to apply this info to solve your problem, but it's the only thing I can think of that might be doing it.

Is the time on your server right?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
ibolui
Forum Commoner
Posts: 27
Joined: Thu May 26, 2005 9:41 am

Post by ibolui »

my comp is set to +0800. actually i am trying to play around with phpbb. i installed phpbb and i set the board time in admincp to gmt.

i also tried changing my comp to gmt but no use. is there another time setting for the server? where is it and how do i change it?

thanks.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

If you're running your own Linux server, look into the rdate shell command. That will sync your server's time with another server.

If you've set phpBB's time to GMT and you're not in that timezone, that might explain why the times are off. If you set it to where you actually are, the date might make more sense.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Sphen001
Forum Contributor
Posts: 107
Joined: Thu Mar 10, 2005 12:24 pm
Location: Land of the Beaver

Post by Sphen001 »

Hi,

The thing about phpBB's system is that you have to set the server time in the ACP, as well as your local time in the profile page.

Hope this helps :D

Sphen001
Post Reply