473,405 Members | 2,261 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

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...
Mar 10 '08 #1
4 2213
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.
js*******@attglobal.net
==================

Mar 10 '08 #2
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
Mar 10 '08 #3
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.
js*******@attglobal.net
==================

Mar 10 '08 #4
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.
Mar 10 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Symon R | last post by:
This is a bit of a weird one that I haven't yet been able to solve - I'm hoping someone out there can disprove my findings and tell me where I've gone wrong! I have designed a web service that...
13
by: Michael | last post by:
I would like to set the timezone of a thread to allow me to calculate the UTC time for data sourced from a number of time zones. Although this can be done in C and C++, I annot find how to do...
2
by: H. Blijlevens | last post by:
We're currently working on an application (VB.Net) that needs to keep track of times in different timezones. For instance, the application is run in Berlin and needs to display the exact time in...
0
by: Robert Treat | last post by:
I am trying to figure out if there is a way to determine the timezones supported in postgresql from within the database. If you look at...
1
by: Flack | last post by:
Hey guys, I need to compare two times that the user selects. The user selects the hour, date, and timezone (which can be either NY, LN, or HK timezones). How can I compare two dates of...
5
by: Alex | last post by:
Hi My website is hosted in the States (EST), but the website itself is targeted for UK users (GMT). How can I offset the time so that the server reports it as GMT when my ASP.NET app needs to...
5
by: Daz | last post by:
Hello everyone. I am creating a JavaScript project which will allow users to see what time it is in other countries. I am wondering if there's any way to have the server work this out, without...
7
by: David T. Ashley | last post by:
In a web database (PHP), per user, I'd like to allow each user to specify their timezone (this would change how times are adjusted for display for that user). How do I enumerate all possible...
27
by: Sanjay | last post by:
Hi All, I am using pytz.common_timezones to populate the timezone combo box of some user registration form. But as it has so many timezones (around 400), it is a bit confusing to the users. Is...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.