How do i retrieve and display a timestamp from a mysql database using PHP? -
currently i'm using line of code
echo date("f j y g:i:s", $row[date]);
but gives me january 1 1970 2:33:31
i want normal because if don't date("f j y g:i:s",
@ all, 2011-03-02 23:00:30
correct date, displayed in abnormal way
typecast unix_timestamp inside query:
select unix_timestamp(yourdatefield) yourtable
since see responses other answer while ignored, let me elaborate:
there 2 common date types. both numbers, represent duration since given date.
- one number of days (float) since 1900. 1 one day. fraction fraction of day.
- other number of seconds since 1970. can int (whole seconds) or float (including fractional seconds).
if got first date, treat second format, arecounting days seconds. instead of 111 years since 1900, you're counting 111 seconds since 1970. explains why date.
therefore, use unix_timestamp function, convert first float notation timestamp in seconds. needed because type php uses.
Comments
Post a Comment