timezones and time display

This is a discussion on timezones and time display within the PHP Language forums, part of the PHP Programming Forums category; I have a very basic shell script that I would like to include on my webpage, so I'd like ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-10-2008
CptDondo
 
Posts: n/a
Default timezones and time display

I have a very basic shell script that I would like to include on my
webpage, so I'd like to translate it to php:

#!/bin/sh
LANG=ja_JP.UTF-8 TZ=JST-9 date
LANG=cs_CZ.UTF-8 TZ=MET-1METDST date
LANG=en_US.UTF-8 TZ=PST3PDT date

In short, it displays the date and time for a region in that region's
language and default format.

I've been poking around php but I can't find where to set the equivalent
of TZ and LANG for the date() function...
Reply With Quote
  #2 (permalink)  
Old 03-10-2008
CptDondo
 
Posts: n/a
Default Re: timezones and time display

On Sun, 09 Mar 2008 22:19:31 -0500, Jerry Stuckle wrote:

> CptDondo wrote:
>> I have a very basic shell script that I would like to include on my
>> webpage, so I'd like to translate it to php:
>>
>> #!/bin/sh
>> LANG=ja_JP.UTF-8 TZ=JST-9 date
>> LANG=cs_CZ.UTF-8 TZ=MET-1METDST date
>> LANG=en_US.UTF-8 TZ=PST3PDT date
>>
>> In short, it displays the date and time for a region in that region's
>> language and default format.
>>
>> I've been poking around php but I can't find where to set the
>> equivalent of TZ and LANG for the date() function...
>>
>>

> These are set with the date.timezone PHP configuration parameter. The
> default is in your php.ini file; you can change it with ini_set(), i.e.
>
>



so...

ini_set('date.timezone', 'PST3PDT');
echo date();
ini_set('date.timezone', 'MET-1METDST');
echo date();

or would that make something blow a gasket?

What about
date_timezone_set()
I can't find any usage examples....

--Yan
Reply With Quote
  #3 (permalink)  
Old 03-10-2008
Jerry Stuckle
 
Posts: n/a
Default Re: timezones and time display

CptDondo wrote:
> I have a very basic shell script that I would like to include on my
> webpage, so I'd like to translate it to php:
>
> #!/bin/sh
> LANG=ja_JP.UTF-8 TZ=JST-9 date
> LANG=cs_CZ.UTF-8 TZ=MET-1METDST date
> LANG=en_US.UTF-8 TZ=PST3PDT date
>
> In short, it displays the date and time for a region in that region's
> language and default format.
>
> I've been poking around php but I can't find where to set the equivalent
> of TZ and LANG for the date() function...
>


These are set with the date.timezone PHP configuration parameter. The
default is in your php.ini file; you can change it with ini_set(), i.e.

ini_set('date.timezone', 'PST3PDT');

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Reply With Quote
  #4 (permalink)  
Old 03-10-2008
Jerry Stuckle
 
Posts: n/a
Default Re: timezones and time display

CptDondo wrote:
> On Sun, 09 Mar 2008 22:19:31 -0500, Jerry Stuckle wrote:
>
>> CptDondo wrote:
>>> I have a very basic shell script that I would like to include on my
>>> webpage, so I'd like to translate it to php:
>>>
>>> #!/bin/sh
>>> LANG=ja_JP.UTF-8 TZ=JST-9 date
>>> LANG=cs_CZ.UTF-8 TZ=MET-1METDST date
>>> LANG=en_US.UTF-8 TZ=PST3PDT date
>>>
>>> In short, it displays the date and time for a region in that region's
>>> language and default format.
>>>
>>> I've been poking around php but I can't find where to set the
>>> equivalent of TZ and LANG for the date() function...
>>>
>>>

>> These are set with the date.timezone PHP configuration parameter. The
>> default is in your php.ini file; you can change it with ini_set(), i.e.
>>
>>

>
>
> so...
>
> ini_set('date.timezone', 'PST3PDT');
> echo date();
> ini_set('date.timezone', 'MET-1METDST');
> echo date();
>
> or would that make something blow a gasket?
>


It should work, although I've never tried it.

> What about
> date_timezone_set()
> I can't find any usage examples....
>
> --Yan
>


You can use date_default_timezone_set(), but that takes a different
argument, i.e. America/LosAngeles instead of PST3PDT (which I think
should be PST8PDT instead).

See the description in the manual for date_default_timezone_set; it has
a link to the appendix which lists the accepted timezones.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Reply With Quote
  #5 (permalink)  
Old 03-10-2008
Joćo Morais
 
Posts: n/a
Default Re: timezones and time display

Hi there, a couple of days ago I was looking for something similar to,
I'm using:

http://en.php.net/manual/en/function...fiers-list.php

You can check some examples posted on the comments there, it will help
you.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:30 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0