|
|
|
| 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 : |
3 of 5 (graded 2 times) |
| Viewed : |
6796 |
| 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 />");
?> | | |
|
| Checks Date-Input from HTML-Forms and converts to YYYY-MM-DD Format for MySQL Date-Fields Categories : MySQL, Date Time, PHP, Databases | | | Simple conversion functions to change MySQL dates to arrays, arrays to MySQL dates.
Categories : PHP, Arrays, Date Time, Databases, MySQL | | | If you want to create select buttons featuring current date this example will show you how... Categories : Date Time, HTML and PHP, PHP | | | Calendar using Date function Categories : HTML and PHP, PHP, Date Time, Calendar | | | 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 | | | table calendar pretty much does what cal(1) does - prints out a calendar.
Categories : Date Time, PHP, Calendar | | | A Timing Class Categories : PHP, PHP Classes, Date Time | | | Change the background color of a website daily dynamically using the php date function to get the current day of the week and depending on that day, set the background color for the web page. Categories : PHP, Date Time, Beginner Guides, Web Design | | | Shows the current time as a PNG-image. This script does not use the GD
library. You can use it as a benchmark (because it's slow), or as a quick
reference for implementing a simple PNG-file generator. Categories : Graphics, Zlib, Calendar, PHP, Date Time | | | Convert MYSQL timestamp (14) fields back to UNIX epoch (seconds) format for display with the date() function. "revertTimeStamp($timestamp)" Categories : PHP, Date Time, MySQL | | | A wrapper function to format dates coming from a databases with the
same syntax as PHP's date() function. Categories : Date Time, Databases, PHP | | | PHP Calendar Web App Categories : PHP, Databases, MySQL, Date Time, Calendar | | | Calendar class on the same page , suitable for reservation
Categories : PHP, Calendar, Date Time | | | 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 class that uses microtime() to provide easy calculation of elapsed times
Categories : Date Time, PHP, PHP Classes | |
| |
| |
|