Cagecrawler Posted January 28, 2007 Share Posted January 28, 2007 I am trying to show a particular date which is stored in my database as a timestamp. If I echo just the timestamp variable, i get the following:2007-01-28 04:38:23However, I put it into the date function like so:date('j.n H:i',$transactions['time'])This should display 28.1 23:38, but the timestamp isn't recognised and it displays it as if the timestamp was 0 (ie. 1.1.1970). How can I get it to use the right timestamp? Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 28, 2007 Share Posted January 28, 2007 That's not a timestamp, that's a mysql datetime. to make it a timestamp, do strtotime($transactions['time']) - that will make it a timestamp. Quote Link to comment Share on other sites More sharing options...
redarrow Posted January 28, 2007 Share Posted January 28, 2007 [code]<?php$time_wanted=$transactions['time'];$result=strtotime($time_wanted);echo " The correct time wanted is: $result";?>[/code] Quote Link to comment Share on other sites More sharing options...
Cagecrawler Posted January 28, 2007 Author Share Posted January 28, 2007 It works, thanks.I double checked and my database column type is timestamp, so why does it output a datetime? Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 28, 2007 Share Posted January 28, 2007 Are you using mysql? The manual explains this: http://dev.mysql.com/doc/refman/5.0/en/timestamp-4-1.html"TIMESTAMP columns are displayed in the same format as DATETIME columns. In other words, the display width is fixed at 19 characters, and the format is YYYY-MM-DD HH:MM:SS." Quote Link to comment Share on other sites More sharing options...
redarrow Posted January 28, 2007 Share Posted January 28, 2007 To get a good timestamp use a int then insert a timestamp with the statement time(); Quote Link to comment Share on other sites More sharing options...
Cagecrawler Posted January 28, 2007 Author Share Posted January 28, 2007 Yes I am using mysql, and that link explained it all. Thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.