note 44744 added to function.date
| From: | help at okonekpo dot com | Date: | Sun, 15 Aug 2004 04:05:04 +0000 |
| Subject: | note 44744 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-74680@lists.php.net to get a copy of this message | ||
<?
/*
The Purpose of this function is to display the actual time in your time zone if your web host has a
different time from you.
In the function, the variable $timediff is the time difference in seconds
between your actual location and the location of your server or webhost.
If you are ahead of your server type in a positive integer such as 7200.
If you behind your server please enter a negative integer such as -7200.
In the first example you are 2 hours ahead of your server.
In the second example your are 2 hours behind your server.
Our Goal is to capture the actual time at your location and then return a time like Saturday, August
15, 2004 08:55:05 PM EST.
*/
function actualtime () {
$timediff = -7200 ; // The time difference between your server and your time.
$timestamp = date('U'); // The timestamp at your server.
$timestamp = $timestamp + $timediff; // The calculated timestamp at your actual location.
$weekday = date('l', $timestamp); // Day of the week like Saturday.
$month = date('F', $timestamp); // Month of the year Like August.
$day = date('d', $timestamp); // Day of the month like 14
$year = date('Y', $timestamp); // A full numeric representation of a year, 4 digits
like 2004
$hour = date('h', $timestamp); // The time in hours.
$minute = date('i', $timestamp); // The time in minutes.
$seconds = date('s', $timestamp); // The time in seconds.
$am_pm = date('A', $timestamp); // The Uppercase Ante meridiem and Post meridiem AM or
PM.
$suffix = 'Eastern Time' ; // The suffix that you would like to attach at the end
of your date and time.
$actualtimeis = "{$weekday}, {$month} {$day}, {$year} {$hour}:{$minute}:{$seconds} {$am_pm}
{$suffix}" ;
return $actualtimeis ;
// function ends here.
}
echo actualtime (); // Prints something like Saturday, August 14, 2004 12:59:47 PM Eastern Time.
?>
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+44744
Delete -- http://master.php.net/manage/user-notes.php?action=delete+44744&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+44744&report=yes
Search -- http://master.php.net/manage/user-notes.php