nightkarnation Posted March 4, 2011 Share Posted March 4, 2011 Hey Guys! I have the following doubt. When echoing from Server like this: echo "time=" . time(); I get the time in the following raw format: 1299272294 I would really like to echo it with this format: Tue Mar 1 23:50:00 GMT-0300 2011 Is there a way I could do that? Really looking forward for some help on this one, Thanks a lot in advance! Cheers! Quote Link to comment https://forums.phpfreaks.com/topic/229614-echo-time-time-but-format-to-tue-mar-1-235000-gmt-0300-2011-example/ Share on other sites More sharing options...
kenrbnsn Posted March 4, 2011 Share Posted March 4, 2011 You need to use the date() function for format the date string. Ken Quote Link to comment https://forums.phpfreaks.com/topic/229614-echo-time-time-but-format-to-tue-mar-1-235000-gmt-0300-2011-example/#findComment-1182984 Share on other sites More sharing options...
jcbones Posted March 4, 2011 Share Posted March 4, 2011 You would need to use the date() function. echo 'time=' . date('D M j H:i:s eO Y'); I think that is how you specified. Quote Link to comment https://forums.phpfreaks.com/topic/229614-echo-time-time-but-format-to-tue-mar-1-235000-gmt-0300-2011-example/#findComment-1182985 Share on other sites More sharing options...
nightkarnation Posted March 4, 2011 Author Share Posted March 4, 2011 First of all, Thanks a lot guys for the help! Jcbones, that line of code is 95% correct to what I need, theres only one slight change, I am echoing the following: Fri Mar 4 18:10:25 e-0300 2011 and it should be: Fri Mar 4 18:10:25 GMT-0300 2011 Any ideas and/or suggestions? Thanks again! Cheers! Quote Link to comment https://forums.phpfreaks.com/topic/229614-echo-time-time-but-format-to-tue-mar-1-235000-gmt-0300-2011-example/#findComment-1182993 Share on other sites More sharing options...
jcbones Posted March 4, 2011 Share Posted March 4, 2011 What version of PHP are you using? e Timezone identifier (added in PHP 5.1.0) Examples: UTC, GMT, Atlantic/Azores You could just write the GMT in there, it would have to be escaped though. echo 'time=' . date('D M j H:i:s \G\M\TO Y'); Quote Link to comment https://forums.phpfreaks.com/topic/229614-echo-time-time-but-format-to-tue-mar-1-235000-gmt-0300-2011-example/#findComment-1182997 Share on other sites More sharing options...
nightkarnation Posted March 4, 2011 Author Share Posted March 4, 2011 Thanks a lot Jc, It works now! I have Version 4.4.9, could that be the reason? Quote Link to comment https://forums.phpfreaks.com/topic/229614-echo-time-time-but-format-to-tue-mar-1-235000-gmt-0300-2011-example/#findComment-1183002 Share on other sites More sharing options...
jcbones Posted March 4, 2011 Share Posted March 4, 2011 Thanks a lot Jc, It works now! I have Version 4.4.9, could that be the reason? Yes, that is the reason. Quote Link to comment https://forums.phpfreaks.com/topic/229614-echo-time-time-but-format-to-tue-mar-1-235000-gmt-0300-2011-example/#findComment-1183005 Share on other sites More sharing options...
kenrbnsn Posted March 4, 2011 Share Posted March 4, 2011 Yes. You really should upgrade your PHP version to at least 5.2.15. PHP 5 has been out for over 7 years and I don't think version 4 is even supported anymore. Ken Quote Link to comment https://forums.phpfreaks.com/topic/229614-echo-time-time-but-format-to-tue-mar-1-235000-gmt-0300-2011-example/#findComment-1183006 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.