PHP date & mktime function problem

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
olly86
-


Joined: 25 Apr 2003
Posts: 993
Location: Wiltshire, UK

PostPosted: Mon Apr 04, 2005 9:06 pm    Post subject: PHP date & mktime function problem Reply with quote

The following code creates the right date:
Code:
$date = date("l jS F Y", mktime(0,0,0,4,3,2005));


However, if I use the same "0,0,0,4,3,2005" extracted from a database as "$row['Updated']" it shows today's date.
Code:
$date = date("l jS F Y", mktime($row['Updated']));


Does anyone know why this happens?
---
php date function explained.

NOTE: the date is in the "wrong" (American) format, as that is how the function "mktime" requires it.

The date should be displayed as Sunday 3rd April 2005
_________________
Olly
Back to top View user's profile Send private message
Glitch2082
-


Joined: 02 Dec 2004
Posts: 194

PostPosted: Mon Apr 04, 2005 11:01 pm    Post subject: Reply with quote

Code:
$date = date("l jS F Y", mktime(" . $row['Updated'] . "));

_________________
int main() {
cout << "Im Pro Apache";
cin.get();
}
Back to top View user's profile Send private message Send e-mail
olly86
-


Joined: 25 Apr 2003
Posts: 993
Location: Wiltshire, UK

PostPosted: Mon Apr 04, 2005 11:07 pm    Post subject: Reply with quote

thanks, but that's not it. I now get the following error:
Quote:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in E:\Servers\Abyss Web Server\htdocs\Game\info.php on line 27


Line 27 is where that code is located
_________________
Olly
Back to top View user's profile Send private message
Glitch2082
-


Joined: 02 Dec 2004
Posts: 194

PostPosted: Tue Apr 05, 2005 12:54 am    Post subject: Reply with quote

Oops, I didn't see, it wasn't quoted, sorry :P

Quote:
$date = date("l jS F Y", mktime($row['Updated']));


That should work... dunno why it didn't.
_________________
int main() {
cout << "Im Pro Apache";
cin.get();
}
Back to top View user's profile Send private message Send e-mail
olly86
-


Joined: 25 Apr 2003
Posts: 993
Location: Wiltshire, UK

PostPosted: Tue Apr 05, 2005 12:45 pm    Post subject: Reply with quote

thanks, that's worked a treat.
_________________
Olly
Back to top View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group