PDA

View Full Version : Inserting a "date and time"



ptnfl
06-24-2007, 03:33 AM
Is there a way to display the current date and time on my home page?

Peter

MusicGrams4U.com

Watdaflip
06-24-2007, 04:40 AM
Your homepage needs to be made into a php page.

Create a html box and insert the code below

<?=date('F j Y g:i A')?>


If you want to change the date and time formatting visit
http://us2.php.net/manual/en/function.date.php
for a complete list of formatting options

Collectors-info
06-24-2007, 06:01 AM
Your homepage needs to be made into a php page.

Create a html box and insert the code below

<?=date('F j Y g:i A')?>


If you want to change the date and time formatting visit
http://us2.php.net/manual/en/function.date.php
for a complete list of formatting options

Hi watdaflip, is there a way to have this code not work on the server time. It shows a 6 hour time dif in the UK.

Thanks.

Watdaflip
06-24-2007, 06:30 AM
Umm, I am not aware of a built in function, I believe you have to do

<?=date('F j Y g:i A', time()+(3600*6))?>

The format being
<?=date('F j Y g:i A', time()[+ or -](3600*[hours to add or subtract]))?>

Collectors-info
06-24-2007, 07:20 AM
This was perfect <?=date('F j Y g:i A', time()+(3600*6))?> & is a nice 7.15am in the uk. I will have a look through the site you left a link to, to see if there is anything about the hour we loose for winter & summertime savings in the UK.
Must admit i am not sure if other contrys have this or not.


Cheers.

Watdaflip
06-24-2007, 08:47 PM
You can tell if the current day is daylight savings by doing this

if(date('I'))
{
// The time is daylights saving
}
else
{
// The time is normal
}

And adjust the date accordingly. I believe the time adjustment will different depending if you are in the north or south hemisphere. But all you would have to do is and place it in the if else statement above

<?=date('F j Y g:i A', time()+(3600*(6+ or - 1)))?>