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

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.