tom_b Posted February 11, 2007 Share Posted February 11, 2007 Hi, I have a database with a timestamp field. Everything works fine, but when I output it (echo) I want to change the date/time format. I've tried a number of things, no luck, not even sure if it's a Mysql or PHP issue. Any ideas? Thanks, Tom Quote Link to comment https://forums.phpfreaks.com/topic/38081-solved-timestamp/ Share on other sites More sharing options...
AndyB Posted February 11, 2007 Share Posted February 11, 2007 http://ca.php.net/manual/en/function.date.php - read the notes to see how you can format the output date in whatever format you want. Quote Link to comment https://forums.phpfreaks.com/topic/38081-solved-timestamp/#findComment-182303 Share on other sites More sharing options...
Yesideez Posted February 12, 2007 Share Posted February 12, 2007 I've experienced similar problems when I started with this as I was playing with a MySQL datatype of DATETIME and using date() to change the format gave me some weird results. This is what I ended up using in the end: echo date("d-m \a\\t H:i",strtotime($fetch[dt])); If you want only the date and time then remove \a\\t as that only displays the "at" word between the two. The link AndyB posted is very helpful so you can customise the output format. Quote Link to comment https://forums.phpfreaks.com/topic/38081-solved-timestamp/#findComment-182440 Share on other sites More sharing options...
worldworld Posted February 12, 2007 Share Posted February 12, 2007 Here is your answer... Quote Link to comment https://forums.phpfreaks.com/topic/38081-solved-timestamp/#findComment-182700 Share on other sites More sharing options...
tom_b Posted February 12, 2007 Author Share Posted February 12, 2007 Hi!! Well, it took a little work, but I've got it the way I want it now, thanks to all for your help!!! Tom Quote Link to comment https://forums.phpfreaks.com/topic/38081-solved-timestamp/#findComment-182853 Share on other sites More sharing options...
fenway Posted February 13, 2007 Share Posted February 13, 2007 Why not have MySQL do the work? Quote Link to comment https://forums.phpfreaks.com/topic/38081-solved-timestamp/#findComment-183621 Share on other sites More sharing options...
tom_b Posted February 13, 2007 Author Share Posted February 13, 2007 Well, I'd love to have Mysql do all the work, guess I don't know enough about it yet!!! Quote Link to comment https://forums.phpfreaks.com/topic/38081-solved-timestamp/#findComment-183934 Share on other sites More sharing options...
fenway Posted February 13, 2007 Share Posted February 13, 2007 Check out the DATE_FORMAT() function. Quote Link to comment https://forums.phpfreaks.com/topic/38081-solved-timestamp/#findComment-184027 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.