03-24-2010
PHP function for Time Zone conversion
I recently found that PHP doesn't have an inbuilt function for conversion of time/date between multiple time zones and neither could I find a third-party function for the purpose. However, I did find the PEAR class which has inbuilt support for multiple time-zones but it cannot be used by "including" itself in the php page. PEAR class can be used only after installation, which may not be feasible in each and every case.
To avoid the hassles of installation I have written a set of 3 functions in PHP which wil allows you to -
1.
Convert GMT to local time zone
2. Convert local time zone to GMT
3. Convert between two different time zones.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hello again,
under hp-ux i have a file /etc/TIMEZONE. here is definied which timezone i am.
i dont know who reads this file to set after reading the timezone under /usr/lib/tztab.
my 2 questions, who reads the file /etc/TIMEZONE ( which service ) and do i need in the first line to set my... (6 Replies)
Discussion started by: ortsvorsteher
6 Replies
2. UNIX for Dummies Questions & Answers
Hi,
I got an question about changing timezone thrue command line on a SunOS Release 4.1.2 without restarting the computer.
Now it's set on WET and I want to set the timezone to CET (GMT +1)
Plz somebody help me.
Regards
Novisern:confused: (5 Replies)
Discussion started by: Novisern
5 Replies
3. UNIX for Dummies Questions & Answers
Hi,
i am searching to change the timezone on a HP-UX11 system. Since last weekend the summertime started i am not able to change the time to the new time, every day the time changes back to wintertime. I think the problem is that the server is on the wrong timezone. Can someone help me please?... (1 Reply)
Discussion started by: eddyvdv
1 Replies
4. UNIX for Advanced & Expert Users
HI ;
I got Solaris8 installed oon Sunfire V440 .I have TZ=GMT in /etc/TIMEZONE , but when i log in as root i see the date in GMT+1.
So i have every time to "set TZ=GMT ; export $TZ" .
How can i set the TZ=GMT at the startup defenitely.
Thanks
:) (7 Replies)
Discussion started by: oss
7 Replies
5. Solaris
I am running SunOS 5.6. If I login with a ksh shell and type 'date'. I get the correct date and time related to the TZ, that is,
>Tuesday July 27 09:50:25 NZST 2004
However, if I run under crontab, I get this.
>Mon Jul 26 20:49:00 ESTEDT 2004
My question is; Does anyone know how to fix this... (2 Replies)
Discussion started by: lbeard
2 Replies
6. Shell Programming and Scripting
Hi,
Date_ConvTZ of module Date:Manip, converts time zone to specified server but without day time savings...
$mod = Date_ConvTZ($date,"$thisTZ","$serverTZ");
US and UK timezone difference is 5 hrs, but above function will return difference of 4 hrs.
Please help (1 Reply)
Discussion started by: darshakraut
1 Replies
7. Shell Programming and Scripting
Hi
I have a command which returns a timezone, Ej:
root@bsades2: /usr/local/bin # lsuser -a time_last_login israel
israel time_last_login=1279032223
Question: I want to parse this timezone '1279032223' into a 'martes, 13 de julio de 2010 16:43:43' from the ksh shell. Is itt possible?
... (3 Replies)
Discussion started by: iga3725
3 Replies
8. Red Hat
Hi,
I would like to change time zone Linux from IST to US/Canada but not getting the option , I have run the command setup -> timezone configuration but not getting the option of us/canada or pacific us/canada.
Please suggest.
Regards,
Manoj (1 Reply)
Discussion started by: manoj.solaris
1 Replies
9. Solaris
Hi,
On my server timezone is IST, so I have configured the sudo for user to change the date, but when he is changing the date time zone is also getting changed from ist to gmt. using solaris 10. I have checked in /etc/TIMEZONE file in that it is showing TZ=Asia/Calcutta, wheather any other file... (1 Reply)
Discussion started by: manoj.solaris
1 Replies
10. Solaris
hii there...
can you guys help me with TIMEZONE setting on my solaris box
i tried to edit cat /etc/TIMEZONE..but i think it will work after rebooting,
but something i did which took me to GMT
my problem is i have this issue on a server, and i have to fix this without rebooting.
thanks for... (1 Reply)
Discussion started by: 6pound
1 Replies
LEARN ABOUT PHP
intldateformatter.settimezone
INTLDATEFORMATTER.SETTIMEZONE(3) 1 INTLDATEFORMATTER.SETTIMEZONE(3)
IntlDateFormatter::setTimeZone - Sets formatters timezone
Object oriented style
SYNOPSIS
public boolean IntlDateFormatter::setTimeZone (mixed $zone)
DESCRIPTION
Procedural style
boolean datefmt_set_timezone (mixed $zone)
Sets the timezone that will be used when formatting dates or times with this object.
PARAMETERS
o $zone
- The timezone to use for this formatter. This can be specified in the following forms:
o NULL, in which case the default timezone will be used, as specified in the ini setting date.timezone or through the func-
tion date_default_timezone_set(3) and as returned by date_default_timezone_get(3).
o An IntlTimeZone, which will be used directly.
o A DateTimeZone. Its identifier will be extracted and an ICU timezone object will be created; the timezone will be backed by
ICUs database, not PHPs.
o A
string, which should be a valid ICU timezone identifier. See IntlTimeZone.createTimeZoneIDEnumeration(3). Raw offsets such
as "GMT+08:30" are also accepted.
RETURN VALUES
Returns TRUE on success and FALSE on failure.
EXAMPLES
Example #1
IntlDateFormatter.setTimeZone(3) examples
<?php
ini_set('date.timezone', 'Europe/Amsterdam');
$formatter = IntlDateFormatter::create(NULL, NULL, NULL, "UTC");
$formatter->setTimeZone(NULL);
echo "NULL
", $formatter->getTimeZone()->getId(), "
";
$formatter->setTimeZone(IntlTimeZone::createTimeZone('Europe/Lisbon'));
echo "IntlTimeZone
", $formatter->getTimeZone()->getId(), "
";
$formatter->setTimeZone(new DateTimeZone('Europe/Paris'));
echo "DateTimeZone
", $formatter->getTimeZone()->getId(), "
";
$formatter->setTimeZone('Europe/Rome');
echo "String
", $formatter->getTimeZone()->getId(), "
";
$formatter->setTimeZone('GMT+00:30');
print_r($formatter->getTimeZone());
The above example will output:
NULL
Europe/Amsterdam
IntlTimeZone
Europe/Lisbon
DateTimeZone
Europe/Paris
String
Europe/Rome
IntlTimeZone Object
(
[valid] => 1
[id] => GMT+00:30
[rawOffset] => 1800000
[currentOffset] => 1800000
)
SEE ALSO
IntlDateFormatter.getTimeZone(3).
PHP Documentation Group INTLDATEFORMATTER.SETTIMEZONE(3)