inSaneELF Posted September 3, 2007 Share Posted September 3, 2007 Hi, I'm trying to modify a script I got. I'm not much of a php person, so I need some help. Currently, the script has dates formatted in the European way (day, month, year) and time is in 24-hour mode. I want dates to be month, day, year and time in 12-hour mode. I tried changing this to fix the date: header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 86400) . ' GMT'); To this: header('Expires: ' . gmdate('D, M d Y H:i:s', time() + 86400) . ' GMT'); That change had no apparent effect, so I'm not sure what to do. It's probably something really obvious and I just don't see it. Any help would be appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/67814-help-changing-date-and-time-format/ Share on other sites More sharing options...
AdRock Posted September 3, 2007 Share Posted September 3, 2007 try this: ('D M, jS Y h:i:s') g / h Hour in 12-hour format (1-12) / (01-12) j / d Day of month (1-31) / (01-31) D / l Day of week (Mon-Sun) / (Monday-Sunday) M / F Month (Jan-Dec) / (January-December) S English ordinal suffic ("th","nd","st") Quote Link to comment https://forums.phpfreaks.com/topic/67814-help-changing-date-and-time-format/#findComment-340893 Share on other sites More sharing options...
inSaneELF Posted September 3, 2007 Author Share Posted September 3, 2007 Now this seems strange. I removed this entire line: header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 86400) . ' GMT'); And the date and time still appear (in the wrong format, of course). Now I'm just confused. Quote Link to comment https://forums.phpfreaks.com/topic/67814-help-changing-date-and-time-format/#findComment-340935 Share on other sites More sharing options...
inSaneELF Posted September 4, 2007 Author Share Posted September 4, 2007 Bump. Quote Link to comment https://forums.phpfreaks.com/topic/67814-help-changing-date-and-time-format/#findComment-341570 Share on other sites More sharing options...
inSaneELF Posted September 5, 2007 Author Share Posted September 5, 2007 Okay, I've found two different lines of code which look like they are for formatting the date. Here they are: header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 86400) . ' GMT'); function get_date($date_format = 'j F Y, g:i a') Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/67814-help-changing-date-and-time-format/#findComment-341766 Share on other sites More sharing options...
sebthib55 Posted September 5, 2007 Share Posted September 5, 2007 Let me see if I can help you out... Lets say you have a variable that is a time (123124344)...It normaly is made out of numbers, am I right? Example: $time Now to transform it into a date... (September 4 2007 - 6:34 PM) We will call this variable $datetime This is the query you would use. $datetime=date("F jS Y - h:i A", $time); If you only want the date and no time: $datetime=date("F jS Y", $time); I hope that clears it up... Quote Link to comment https://forums.phpfreaks.com/topic/67814-help-changing-date-and-time-format/#findComment-341817 Share on other sites More sharing options...
Yesideez Posted September 5, 2007 Share Posted September 5, 2007 The line starting header is setting a header. The second is defining a function called get_date() which can be called with a parameter (date/time formatting string) but if that string isn't present then a default one is used instead. gmdate() is exactly the same as date() except it returns the date/time as it is in the GMT time zone. Quote Link to comment https://forums.phpfreaks.com/topic/67814-help-changing-date-and-time-format/#findComment-341836 Share on other sites More sharing options...
inSaneELF Posted September 5, 2007 Author Share Posted September 5, 2007 Thanks for the replies. So is this what the code should look like? function get_date($datetime=date("F jS Y - h:i A", $time); Quote Link to comment https://forums.phpfreaks.com/topic/67814-help-changing-date-and-time-format/#findComment-342322 Share on other sites More sharing options...
jeppers Posted September 5, 2007 Share Posted September 5, 2007 Try this just cut and paste and see what u think <?php echo '<p>Today is ' . date ('l') . '. The current time is ' . date ('g: i a') .'.</p>'; ?> i am new aswell Quote Link to comment https://forums.phpfreaks.com/topic/67814-help-changing-date-and-time-format/#findComment-342457 Share on other sites More sharing options...
inSaneELF Posted September 6, 2007 Author Share Posted September 6, 2007 Try this just cut and paste and see what u think <?php echo '<p>Today is ' . date ('l') . '. The current time is ' . date ('g: i a') .'.</p>'; ?> i am new aswell That got me: Parse error: syntax error, unexpected '<', expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/username/www/www/modules/mod_jw_srfr/simplepie.inc on line 1337 Quote Link to comment https://forums.phpfreaks.com/topic/67814-help-changing-date-and-time-format/#findComment-342628 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.