|
|
|
| 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 : |
4355 |
| 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 />");
?> | | |
|
| Local-to-user date and time display regardless of time zone or where the website's server is located Categories : PHP, Date Time, HTML and PHP, Java Script | | | Script loading time Categories : PHP, Beginner Guides, Date Time | | | Spreadsheet Date Calculations in PHP Categories : PHP, Date Time, Excel | | | formating MySQL Timestamp to get a propper Output.
related : Timestamp, ereg_replace, mysql, substr Categories : MySQL, PHP, Date Time, Databases | | | Simple PHP control CSS Calendar Categories : PHP, HTML and PHP, Calendar, Date Time, CSS | | | A PHP Script that shows how to use FTP to run a shell script, read two local files and update data in a database. Categories : PHP, Filesystem, FTP, Date Time, Databases | | | Query2Report : Generating Html, Pdf and Csv Reports from SQL Query Categories : PHP, PHP, HTML, PDF, Excel | | | This script obtains the current Universal Time from the National Institute of Standards and Technology of the United States of America. Categories : PHP, Date Time | | | How to Insert a Date Format Into MySQL from PHP Categories : PHP, Databases, MySQL, Date Time, Beginner Guides | | | A time measuring and performance benchmarking class Categories : PHP, PHP Classes, Testing, Debugging, Date Time | | | Function that returns an array with the 7 dates of the week that belong to the supplied date. Categories : PHP, Date Time, Arrays | | | Query Timer Categories : PHP, Databases, Date Time | | | mysql date/time converters Categories : PHP, MySQL, Databases, Date Time | | | This code consists of two parts, the first part is a .html file that uses a form to pass 3 date variables into day_of_week.php3 You input the mm/dd/yyyy of the day then
it prints what day of the week that day falls on. Categories : Date Time, PHP, Complete Programs | | | Find the day of the week for any given year/month/day. Categories : PHP, Date Time, Data Validation, Algorithms, Beginner Guides | |
|
|