JP128 Posted December 17, 2006 Author Share Posted December 17, 2006 the dob is a var char... Link to comment https://forums.phpfreaks.com/topic/30938-solved-inserting-date-into-mysql/page/2/#findComment-143199 Share on other sites More sharing options...
JP128 Posted December 17, 2006 Author Share Posted December 17, 2006 Ok, here is all the info... the column join date is a timestamp.I insert into that column with a mysql_query, and the now() function.when I call that date, and try to format it into m/d/Y h:i:s ... it always comes out Dec, 31 1969 4:33:26 PM... Link to comment https://forums.phpfreaks.com/topic/30938-solved-inserting-date-into-mysql/page/2/#findComment-143215 Share on other sites More sharing options...
JP128 Posted December 18, 2006 Author Share Posted December 18, 2006 Something that I found on the internet...POST: LOL - it says "Googlebot last successfully accessed your home page on Dec 31, 1969" - does that make my site on of the oldest on the net? :)REPLYActually, that date occurs when a timestamp isn't valid...looks like a possible but in the code. ;) Link to comment https://forums.phpfreaks.com/topic/30938-solved-inserting-date-into-mysql/page/2/#findComment-143224 Share on other sites More sharing options...
chiprivers Posted December 18, 2006 Share Posted December 18, 2006 When you use the date() function to format the display of a date and/or time in php, the specified date/time should be in a timestamp format, not as returned from the mysql database. A timestamp is an int that represents the number of seconds passed since the epoch (01 Jan 1970).To use the date() function you should convert your returned datetime valye from mysql using the strtotime() function.try this:<?php$time = strtotime($row['joined_date']);$newTime = date("m/d/Y h:i:s",$time);?> Link to comment https://forums.phpfreaks.com/topic/30938-solved-inserting-date-into-mysql/page/2/#findComment-143225 Share on other sites More sharing options...
trq Posted December 18, 2006 Share Posted December 18, 2006 Pfff... my bad. I completely overlooked that. Maybe I need a break? Link to comment https://forums.phpfreaks.com/topic/30938-solved-inserting-date-into-mysql/page/2/#findComment-143228 Share on other sites More sharing options...
JP128 Posted December 18, 2006 Author Share Posted December 18, 2006 Wow... I am sorry that I took your time... I didnt realize that the error was that simple, because I have tried that once, and I had a different time... Well, Thanks Thorpe! Link to comment https://forums.phpfreaks.com/topic/30938-solved-inserting-date-into-mysql/page/2/#findComment-143252 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.