|
Posted by Erwin Moller on 11/04/05 15:03
Jonathan Crawford wrote:
> Hi
>
> I am niew to pho and am having trouble with dates.
Read the manual. :-)
Really, it is the only things that helps.
www.php.net
>
> I can format a date ok
> so $today=date('d M Y' )
> gives me 2 Nov 2005
which is fine.
Except for the fact it is 4 november over here, is your time ok?
>
>
> $dateval is a mysql date
> yyyy-mm-dd hh:nn:sss (2005-10-26 13:32:09)
> $today=date('d M Y' ,$dateval)
And here you go wrong.
Did you read what date() does in PHP?
Check the manual: It says:
-----------------------------------------
Description
string date ( string format [, int timestamp] )
Returns a string formatted according to the given format string using the
given integer timestamp or the current local time if no timestamp is given.
In other words, timestamp is optional and defaults to the value of time().
Note: To generate a timestamp from a string representation of the date, you
may be able to use strtotime(). Additionally, some databases have functions
to convert their date formats into timestamps (such as MySQL's
UNIX_TIMESTAMP function).
-----------------------------------------
So.....
What you should do is:
1) read the manual
2) make sure you know how your date is represented in mySQL, and how PHP
wants it. Have a look at strtotime() and the like for help.
In general: if a function is not behaving as expected, read the manual and
see what is says.
On www.php.net: if you cannot find your problem/answer, be sure to read the
visitorscomments too, they often contain usefull information.
> gives me something like 1 july 1970
>
> I am not sure how to tell the php that the date is a date.
>
> It is driving me nuts, and the only particulary
> obscure thing I have encountered so far.
rtfm.
>
> i would be grateful for some advice
>
> thanks
>
> jonathan
>
Good luck!
Regards,
Erwin Moller
Navigation:
[Reply to this message]
|