EchoFool Posted September 26, 2011 Share Posted September 26, 2011 Hey, Is there a PHP function that converts a timestamp to words automatically? I have the timestamp in this format: 0000-00-00 00:00:00 But i want it to display into words like for example: Mon 12th December 2011 8:00PM Can't work out how to do it with my own function it seems over complex to work out what day it would be so am wondering if PHP already has a such a function? Quote Link to comment https://forums.phpfreaks.com/topic/247905-covnertime-timestamp-to-words/ Share on other sites More sharing options...
requinix Posted September 26, 2011 Share Posted September 26, 2011 Is there a PHP function that converts a timestamp to words automatically? Yes. Quote Link to comment https://forums.phpfreaks.com/topic/247905-covnertime-timestamp-to-words/#findComment-1272965 Share on other sites More sharing options...
EchoFool Posted September 26, 2011 Author Share Posted September 26, 2011 I saw that function though i don't get how it converts it to what i need? If i put <?php date("Y-m-d H:i:s",time()); ?> That just gives me the server time, but im trying to convert a stored timestamp from the database... Quote Link to comment https://forums.phpfreaks.com/topic/247905-covnertime-timestamp-to-words/#findComment-1272967 Share on other sites More sharing options...
EchoFool Posted September 26, 2011 Author Share Posted September 26, 2011 Argh i worked it out Had to use strtotime() in order for it to work on my variable! Thanks for the tip! Quote Link to comment https://forums.phpfreaks.com/topic/247905-covnertime-timestamp-to-words/#findComment-1272972 Share on other sites More sharing options...
requinix Posted September 26, 2011 Share Posted September 26, 2011 If you're getting it from MySQL then there's also DATE_FORMAT. Quote Link to comment https://forums.phpfreaks.com/topic/247905-covnertime-timestamp-to-words/#findComment-1272992 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.