spires Posted May 13, 2008 Share Posted May 13, 2008 Hi Guys. what parameter do I need in the date function to output - 3rd March 08 Link to comment https://forums.phpfreaks.com/topic/105420-solved-simple-date-question/ Share on other sites More sharing options...
revraz Posted May 13, 2008 Share Posted May 13, 2008 http://us3.php.net/date Link to comment https://forums.phpfreaks.com/topic/105420-solved-simple-date-question/#findComment-539861 Share on other sites More sharing options...
soycharliente Posted May 13, 2008 Share Posted May 13, 2008 All of the codes can be found here: http://us3.php.net/date <?php echo date("jS F y", $thedate); ?> Link to comment https://forums.phpfreaks.com/topic/105420-solved-simple-date-question/#findComment-539862 Share on other sites More sharing options...
spires Posted May 13, 2008 Author Share Posted May 13, 2008 Thats excellent - Thanks :-) Link to comment https://forums.phpfreaks.com/topic/105420-solved-simple-date-question/#findComment-539866 Share on other sites More sharing options...
soycharliente Posted May 13, 2008 Share Posted May 13, 2008 Mark SOLVED please. Link to comment https://forums.phpfreaks.com/topic/105420-solved-simple-date-question/#findComment-539881 Share on other sites More sharing options...
spires Posted May 13, 2008 Author Share Posted May 13, 2008 Thats excellent - Thanks :-) I've tried: <?php $thedate = date("Y m d"); echo date("jS F y", $thedate); ?> But the code only echos 1st January 70. Any ideas? Link to comment https://forums.phpfreaks.com/topic/105420-solved-simple-date-question/#findComment-539885 Share on other sites More sharing options...
947740 Posted May 13, 2008 Share Posted May 13, 2008 $thedate has to be a UNIX timestamp. E.G. $thedate = strtotime("now"); Link to comment https://forums.phpfreaks.com/topic/105420-solved-simple-date-question/#findComment-539886 Share on other sites More sharing options...
soycharliente Posted May 13, 2008 Share Posted May 13, 2008 Use strtotime. http://us.php.net/strtotime <?php $thedate = date("Y m d"); echo date("jS F y", strtotime($thedate)); ?> Link to comment https://forums.phpfreaks.com/topic/105420-solved-simple-date-question/#findComment-539888 Share on other sites More sharing options...
revraz Posted May 13, 2008 Share Posted May 13, 2008 Yes, read the links we posted above. Thats excellent - Thanks :-) Any ideas? Link to comment https://forums.phpfreaks.com/topic/105420-solved-simple-date-question/#findComment-539889 Share on other sites More sharing options...
947740 Posted May 13, 2008 Share Posted May 13, 2008 I am assuming (even though I should not) that if you do not supply a timestamp, the date function automatically uses the current time? You could just do <?phpecho date("jS F y", strtotime("now"));?> , thusly removing the other line of code. Link to comment https://forums.phpfreaks.com/topic/105420-solved-simple-date-question/#findComment-539891 Share on other sites More sharing options...
spires Posted May 13, 2008 Author Share Posted May 13, 2008 Cheers guys. Perfect. Thanks for your help. Link to comment https://forums.phpfreaks.com/topic/105420-solved-simple-date-question/#findComment-539894 Share on other sites More sharing options...
soycharliente Posted May 13, 2008 Share Posted May 13, 2008 I am assuming (even though I should not) that if you do not supply a timestamp, the date function automatically uses the current time? You are correct. Returns a string formatted according to the given format string using the given integer timestamp or the current time if no timestamp is given. In other words, timestamp is optional and defaults to the value of time(). So theoretically you could just say <?php echo date("jS F y"); ?> for the same effect as formatting the time right now. Link to comment https://forums.phpfreaks.com/topic/105420-solved-simple-date-question/#findComment-539897 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.