Jump to content

Help Changing Date and Time Format


inSaneELF

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/67814-help-changing-date-and-time-format/
Share on other sites

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")

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?

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... :)

 

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.

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.