date() outputting a notice and Thursday January 1970

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
.Stealth
Forum Commoner
Posts: 57
Joined: Wed Jan 10, 2007 12:15 pm
Location: Manchester, England

date() outputting a notice and Thursday January 1970

Post by .Stealth »

hello, just wondering if anybody can help me solve a little problem.

i am wanting to output a date from my mysql database as words, like:

wednesday 20th june 2007, but when i use the date function to convert the mysql version, it outputs this:
Notice: A non well formed numeric value encountered in /*******/***/client_area/tickets.php on line 104
Date: Thursday January 1970
(i can tell why its jan 1970, because thats what php works off so its defaulting to that)

im not usually that bad at guessing what notices mean but this one i cant.

im guessing its something to do with the mysql.


first of all, here's my code:

Code: Select all

$ticket_get_replys 	= @mysql_query("SELECT * FROM ticket_replys WHERE ticket_reply_id = '$ticket_id';");
	while($ticket_replys = mysql_fetch_array($ticket_get_replys)){
		
		$ticket_reply_time		= $ticket_replys['ticket_reply_time'];
		$ticket_reply_date		= $ticket_replys['ticket_reply_date'];
		$ticket_reply_date		= date("l F Y","$ticket_reply_date");
		$ticket_reply_message	= $ticket_replys['ticket_reply'];
		echo "Date: $ticket_reply_date
		<br />$ticket_reply_message<br />
		---------------------------<br />";
	}
	
	echo "</p>";

when called, the $ticket_reply_date will be a value of:

2007-06-19

so i think it could be to do with the hyphens being there or something.

anybody got an idea why this is hapening?

thanks for any help
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

date() requires a unix timestamp. Is your mysql date in timestamp form? If not, strtotime() might be of some interest to you.
.Stealth
Forum Commoner
Posts: 57
Joined: Wed Jan 10, 2007 12:15 pm
Location: Manchester, England

Post by .Stealth »

ohh right, thanks alot for that, worked a treat.

my mysql dates where like:
00-00-0000

so i guess not, the strtotime() worked perfect though.

thankyou :)
Post Reply