PHP Experience
Timothy J. Finucane
speljamr at speljamr.com
Wed Oct 27 21:49:58 EDT 2004
Your problem appears to be some conflicting terms. Timestamp, when
refered to in the PHP date() function, refers to a Unix Timestamp. The
timestamp data type in MySQL is not a Unix Timestamp. To run the date
function on the output from MySQL you need to convert the date to a Unix
Timestamp. You can do this with the UNIX_TIMESTAMP function in MySQL
(http://dev.mysql.com/doc/mysql/en/Date_and_time_functions.html) or with
the PHP strtotime() function
(http://us2.php.net/manual/en/function.strtotime.php)
That should clear up your date issue.
Take a look at these two pages:
http://dev.mysql.com/doc/mysql/en/TIMESTAMP_pre-4.1.html
http://us2.php.net/manual/en/function.date.php
Tim
--
“They that can give up essential liberty to obtain a little temporary
safety deserve neither liberty nor safety.” —Benjamin Franklin
On Wed, 2004-10-27 at 20:24, adelphia wrote:
> Hi Tim,
>
> I'm working on my first mySql project. I have a web form, for inserting
> a date field into mySql.
> The field in the table is set to timestamp in mySql.
>
> I prepare the data for insert with:
>
> list($month, $day, $year) = split('[/.-]', $_POST['Event_Date_Start']);
> $Event_Date_Start = $year."-".$month."-".$day;
>
> And it is stored in mySql as "20041027164404"
>
> I query the records, and recall the Event_Date_Start record to display on
> the page:
>
> $num=mysql_numrows($result);
> $i=0;
> while ($i < $num) {
> $Event_Date_Start=mysql_result($result,$i,"Event_Date_Start");
> echo date("l, F j, Y",$Event_Date_Start)." at ".$Event_Time_Start;
> }
>
> Now, here's the result:
> Monday, January 18, 2038
>
>
> It's an incorrect date.It should be Saturday, November 27, 2004. I'm
> stumped, after perusing through pages and pages of PHP manuals, there's
> little reference to fix this with mySql and php.. Any help with this would
> be appreciated...
>
> PS: it's not any better using date("l, F j,
> Y",strtotime($Event_Date_Start));
>
> Any thoughts?
>
> Scott
>
>
>
>
> ----- Original Message -----
> From: "Timothy J. Finucane" <speljamr at speljamr.com>
> To: <nflug at nflug.org>
> Sent: Wednesday, October 27, 2004 7:52 PM
> Subject: Re: PHP Experience
>
>
> I have a good amount of experience with PHP/MySQL. What kind of
> assistance do you require?
>
> Tim
More information about the nflug
mailing list