|
|
|
| Title : |
A simple function to get the UTC offset of your location. Handy for sites that don't have more recent versions of PHP with date/time functions with options that return the offset. |
| Categories : |
PHP, Date Time |
 Dave Silvia |
| Date : |
Nov 08th 2006 |
| Grade : |
1 of 5 (graded 1 times) |
| Viewed : |
2790 |
| File : |
4523.php
|
| Images : |
No Images for this code example. |
|
| Search : |
More code by Dave Silvia |
|
| Action : |
Grade This Code Example
|
|
| Tools : |
My Examples List |
|
|
|
|
|
|
(c) 2006, D.E. Silvia, All rights reserved.
This code is available for use for non-commercial purposes.
Free to distribute as long as this copyright information remains intact.
No modification is authorized. Please, refer bugs/enhancements to
dsilvia@mchsi.com
A simple function to get the UTC offset of your location. Handy for sites that don't have
more recent versions of PHP with date/time functions with options that return the offset.
| <?php
function utcOffset()
{
$gmTime=mktime(gmdate("H"),gmdate("i"),gmdate("s"),gmdate("m"),gmdate("d"),gmdate("Y"));
$nowLocal=time();
$offset=($nowLocal-$gmTime)/3600;
$sign=($offset >= 0) ? "+" : "-";
$offset=(substr($offset,0,1) == "-") ? substr($offset,1) : $offset;
$pad=(strlen($offset) == 1) ? "0" : "";
return $sign.$pad.$offset."00";
}
?> | |
Usage Example
| <?php
print("My local time zone's UTC offset is: ".utcOffset()."<br />");
?> | | |
|
| A Timing Class Categories : PHP, PHP Classes, Date Time | | | Finding the day of the week for a specific date.
Categories : PHP, Databases, MySQL, Date Time | | | A wrapper function to format dates coming from a databases with the
same syntax as PHP's date() function. Categories : Date Time, Databases, PHP | | | pcCalendar class - Allows for the creation of calendars in HTML pages. All output functions can be easily overridden, refer to article 1471 for an example.
Categories : PHP, Date Time, Calendar, PHP Classes | | | A PHP Calendar function with CSS : add a cool calendar to any php page by just adding a calendar class based function. Categories : PHP, PHP Classes, Calendar, Date Time | | | PHP Round Clock - Must have Gif support to use this. Categories : PHP, Date Time, Graphics | | | A simple and fast calendar combining PHP and tables. Use this as a base for applications in which a calendar is needed. Categories : Date Time, PHP, Complete Programs, Calendar | | | Open and Close your website in fixed times . Categories : PHP, PHP Classes, Cron, Date Time | | | mysql date/time converters Categories : PHP, MySQL, Databases, Date Time | | | Creates three SELECT form fields: Month, Day, and Year. You give it a string which will be used to make the name for the three fields, and a number of seconds to use as the default date. If you give it blank for this value, the current date is used. Categories : HTML and PHP, PHP, Date Time | | | If you want to create select buttons featuring current date this example will show you how... Categories : Date Time, HTML and PHP, PHP | | | Example of using the pcCalendar class, article 1468 on weberdev.com. Calendar example. Categories : PHP, Date Time, PHP Classes, Calendar | | | calculus of the eastersunday Categories : BC math, PHP, Date Time, Databases | | | Functions used to define a schedule of holidays. Can define non-fixed holidays (eg. 3rd sunday of June). Categories : Calendar, Date Time, PHP | | | Monthly and Daily Upcoming Events calendar. Categories : Date Time, PostgreSQL, PHP, Calendar, Databases | |
|
|
|