Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how di identify a string with contents?

1 view
Skip to first unread message

John Kopf

unread,
Dec 30, 2009, 2:09:06 AM12/30/09
to
can build a sparse array thus:
<?php
$Hday = array;
$Hday['07/04']="Happy Forth of July";
$Hday["12/25']="Merry Christmas";
?>

later, I can say:

<?php
$today=date("m/d");
$event=Hday[$today];
?>

My question is how do I determine if $event actually captured anything?
Is a statement of the form:

if(strlen($event)>0) go do something

the "simplest" way, or would you recommend some other test?

John Kopf

Michael Fesser

unread,
Dec 30, 2009, 3:13:02 AM12/30/09
to
.oO(John Kopf)

> can build a sparse array thus:
><?php
> $Hday = array;
> $Hday['07/04']="Happy Forth of July";
> $Hday["12/25']="Merry Christmas";
>?>
>
>later, I can say:
>
><?php
> $today=date("m/d");
> $event=Hday[$today];
>?>
>
>My question is how do I determine if $event actually captured anything?
>Is a statement of the form:
>
> if(strlen($event)>0) go do something

Two notes:

1) Checking the length of a string just to test whether it's empty or
not is unnecessary and quite ugly. A simple $event != '' does the same.
Or call empty() if you also want to allow for NULL values.

2) Here in this example this line

$event=Hday[$today];

will trigger an E_NOTICE error if there's no entry in the array for the
current date. You should check with isset() if there's one:

$today = date('m/d');
$event = isset($Hday[$today]) ? $Hday[$today] : '';

And then:

if ($event != '') {
... // do something with $event
}

You could also do it like this:

$today = date('m/d');
if (isset($Hday[$today])) {
... // do something with $Hday[$today]
}

HTH
Micha

C. (http://symcbean.blogspot.com/)

unread,
Dec 30, 2009, 5:49:20 PM12/30/09
to
On 30 Dec, 08:13, Michael Fesser <neti...@gmx.de> wrote:
> .oO(John Kopf)
>
>
>
> >  can build a sparse array thus:
> ><?php
> >  $Hday = array;
> >  $Hday['07/04']="Happy Forth of July";
> >  $Hday["12/25']="Merry Christmas";
> >?>
<snip>

>
> You could also do it like this:
>
>   $today = date('m/d');
>   if (isset($Hday[$today])) {
>      ... // do something with $Hday[$today]
>   }
>

This would still throw a warning because the array key does not exist.
So a cleaner solution might be:

if (array_key_exists($today, $Hday)) { ...

C.

Michael Fesser

unread,
Dec 31, 2009, 6:08:35 AM12/31/09
to
.oO(C. (http://symcbean.blogspot.com/))

>On 30 Dec, 08:13, Michael Fesser <neti...@gmx.de> wrote:
>> .oO(John Kopf)
>>
>>
>>
>> > �can build a sparse array thus:
>> ><?php
>> > �$Hday = array;
>> > �$Hday['07/04']="Happy Forth of July";
>> > �$Hday["12/25']="Merry Christmas";
>> >?>
><snip>
>>
>> You could also do it like this:
>>
>> � $today = date('m/d');
>> � if (isset($Hday[$today])) {
>> � � �... // do something with $Hday[$today]
>> � }
>>
>
>This would still throw a warning because the array key does not exist.

No problem, isset() can handle this.

>So a cleaner solution might be:
>
>if (array_key_exists($today, $Hday)) { ...

Not necessary here.

Micha

Ivan S

unread,
Dec 31, 2009, 10:15:00 AM12/31/09
to
On Dec 30, 9:13 am, Michael Fesser <neti...@gmx.de> wrote:
> Or call empty() if you also want to allow for NULL values.

Using empty() can be tricky if one doesn't know what will be evaluated
as true. For example, zero ~ "0" as a string evaluates as true and
it's not empty string or null.

$test = '0';

$test === NULL || $test === '' // false
is not equal as
empty($test) // true


I think this should be mentioned.


***

From: http://php.net/manual/en/function.empty.php

Returns FALSE if var has a non-empty and non-zero value.

The following things are considered to be empty:

* "" (an empty string)
* 0 (0 as an integer)
* "0" (0 as a string)
* NULL
* FALSE
* array() (an empty array)
* var $var; (a variable declared, but without a value in a class)

***

I would do something like this:

$event = isset($Hday[$today]) ? $Hday[$today] : FALSE;

if ($event !== FALSE) {
...
}


i.

John O. Kopf

unread,
Jan 1, 2010, 7:39:52 PM1/1/10
to

That works fine (see the result at http://www.scvcma.org/ - within the
next 4 hours - then it disappears again )

Thank yo9u for your kind assistance.

John Kopf

John O. Kopf

unread,
Jan 2, 2010, 1:15:12 PM1/2/10
to
The code I used was:

<?php
$Tday = date( "m/d" ); // today
if ( isset( $Hday[ $Tday ] ) )
{
$Event = $Hday[ $Tday ];
echo( "<script><!--\n" );
echo( " HolidayBlock( " . $Event . ")\n" );
echo( "--></script>\n" );
}
?>

...Unfortunately, even though we're located in California, our Server is
in EST; the result is that "$Tday = date( "m/d" ); // today" rolls over
to the next day at 9pm our time.

Is there some easy way to specify I want PST, in the date() call? I
can't seem to find any examples online.

John Kopf

John O. Kopf wrote:
> Michael Fesser wrote:
>> .oO(John Kopf)
>>

>>> SNIO


>>
>> $today = date('m/d');
>> if (isset($Hday[$today])) {
>> ... // do something with $Hday[$today]
>> }
>>
>> HTH
>> Micha
>
> That works fine (see the result at http://www.scvcma.org/ - within the
> next 4 hours - then it disappears again )
>

> Thank you for your kind assistance.
>
> John Kopf
>

Beauregard T. Shagnasty

unread,
Jan 2, 2010, 2:05:14 PM1/2/10
to
John O. Kopf wrote:

> <?php
> $Tday = date( "m/d" ); // today

> Is there some easy way to specify I want PST, in the date() call? I

> can't seem to find any examples online.

Place this as the first line:
date_default_timezone_set("America/Los_Angeles");

--
-bts
-Four wheels carry the body; two wheels move the soul

Jerry Stuckle

unread,
Jan 2, 2010, 2:42:06 PM1/2/10
to
Beauregard T. Shagnasty wrote:
> John O. Kopf wrote:
>
>> <?php
>> $Tday = date( "m/d" ); // today
>
>> Is there some easy way to specify I want PST, in the date() call? I
>> can't seem to find any examples online.
>
> Place this as the first line:
> date_default_timezone_set("America/Los_Angeles");
>

Better yet - set it in the .htaccess file:

php_value date.timezone "America/Los_Angeles"

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

John O. Kopf

unread,
Jan 5, 2010, 4:56:33 PM1/5/10
to
Beauregard T. Shagnasty wrote:
> John O. Kopf wrote:
>
>> <?php
>> $Tday = date( "m/d" ); // today
>
>> Is there some easy way to specify I want PST, in the date() call? I
>> can't seem to find any examples online.
>
> Place this as the first line:
> date_default_timezone_set("America/Los_Angeles");
>

I did - got:

Fatal error: Call to undefined function: date_default_timezone_set() in
/nfs/cust/0/66/74/547660/web/NewStuff/M_Main/MainPage.php on line 5

Any suggestions?

John Kopf

Beauregard T. Shagnasty

unread,
Jan 5, 2010, 5:24:19 PM1/5/10
to
John O. Kopf wrote:

What version of PHP is your server using?
http://php.net/manual/en/function.date-default-timezone-set.php
Says: (PHP 5 >= 5.1.0)

Either that, or your path or syntax is incorrect.

John O. Kopf

unread,
Jan 18, 2010, 1:14:11 PM1/18/10
to
Beauregard T. Shagnasty wrote:
> John O. Kopf wrote:
>
>> Beauregard T. Shagnasty wrote:
>>> John O. Kopf wrote:
>>>> <?php
>>>> $Tday = date( "m/d" ); // today
>>>> Is there some easy way to specify I want PST, in the date() call? I
>>>> can't seem to find any examples online.
>>> Place this as the first line:
>>> date_default_timezone_set("America/Los_Angeles");
>> I did - got:
>>
>> Fatal error: Call to undefined function: date_default_timezone_set() in
>> /nfs/cust/0/66/74/547660/web/NewStuff/M_Main/MainPage.php on line 5
>>
>> Any suggestions?
>
> What version of PHP is your server using?
> http://php.net/manual/en/function.date-default-timezone-set.php
> Says: (PHP 5 >= 5.1.0)
>
> Either that, or your path or syntax is incorrect.
>
How do I determine the version of php?

John Kopf

Peter H. Coffin

unread,
Jan 18, 2010, 2:02:28 PM1/18/10
to

The results of the phpinfo() function will tell you.

--
67. No matter how many shorts we have in the system, my guards will be
instructed to treat every surveillance camera malfunction as a
full-scale emergency.
--Peter Anspach's list of things to do as an Evil Overlord

Warren Oates

unread,
Jan 18, 2010, 2:44:53 PM1/18/10
to
In article <slrnhl9c24....@abyss.ninehells.com>,

"Peter H. Coffin" <hel...@ninehells.com> wrote:

>
> The results of the phpinfo() function will tell you.

php -v

from the prompt.
--
Very old woody beets will never cook tender.
-- Fannie Farmer

Peter H. Coffin

unread,
Jan 18, 2010, 5:06:44 PM1/18/10
to
On Mon, 18 Jan 2010 14:44:53 -0500, Warren Oates wrote:
> In article <slrnhl9c24....@abyss.ninehells.com>,
> "Peter H. Coffin" <hel...@ninehells.com> wrote:
>
>>
>> The results of the phpinfo() function will tell you.
>
> php -v
>
> from the prompt.

... presuming of course that the php that you get from the prompt is the
same php as the one on "the server", and uses the same php.ini... That's
not a situation that's obtained in no small number of funny,
inconsistent problems people have reported here.

--
36. I will not imprison members of the same party in the same cell
block, let alone the same cell. If they are important prisoners, I
will keep the only key to the cell door on my person instead of
handing out copies to every bottom-rung guard in the prison. --EOList

Warren Oates

unread,
Jan 18, 2010, 6:15:48 PM1/18/10
to
In article <slrnhl9mrk....@abyss.ninehells.com>,

"Peter H. Coffin" <hel...@ninehells.com> wrote:

> ... presuming of course that the php that you get from the prompt is the
> same php as the one on "the server", and uses the same php.ini... That's
> not a situation that's obtained in no small number of funny,
> inconsistent problems people have reported here.

True. I tend to use PHP for everything, and I manage to get my host to
install the bits and pieces I rely on, so my test setup is equal to the
public one. I guess not everyone's so lucky.

John O. Kopf

unread,
Jan 18, 2010, 7:20:26 PM1/18/10
to
Warren Oates wrote:
> In article <slrnhl9c24....@abyss.ninehells.com>,
> "Peter H. Coffin" <hel...@ninehells.com> wrote:
>
>> The results of the phpinfo() function will tell you.
>
> php -v
>
> from the prompt.

But the only access I have to the server is FTP (I'm using FileZilla) to
install things, and the browser accessing things installed there - I
can't get to a "prompt".

John Kopf

Jerry Stuckle

unread,
Jan 18, 2010, 7:32:13 PM1/18/10
to

As Peter said - use phpinfo().

php -v is not necessarily a good idea - it is very possible the command
line version of PHP is different from the one used by the server.

Beauregard T. Shagnasty

unread,
Jan 18, 2010, 8:04:28 PM1/18/10
to
John O. Kopf wrote:

>> "Peter H. Coffin" <hel...@ninehells.com> wrote:
>>> The results of the phpinfo() function will tell you.
>

> But the only access I have to the server is FTP (I'm using FileZilla)
> to install things, and the browser accessing things installed there -
> I can't get to a "prompt".

Create a file named: phpinfo.php
Put the following contents in it:

<?php
phpinfo()
?>

FTP it to your server. Open your browser and access it.

http://example.com/info.php

Run it on your home server as well.

Beauregard T. Shagnasty

unread,
Jan 18, 2010, 8:37:22 PM1/18/10
to
Beauregard T. Shagnasty replied to hisself:

Whoops!
> http://example.com/info.php
http://example.com/phpinfo.php

John O. Kopf

unread,
Jan 19, 2010, 4:12:55 PM1/19/10
to
Peter H. Coffin wrote:
> On Mon, 18 Jan 2010 10:14:11 -0800, John O. Kopf wrote:
>> Beauregard T. Shagnasty wrote:
>>> John O. Kopf wrote:
>>>
>>>> Beauregard T. Shagnasty wrote:
>>>>> John O. Kopf wrote:
>>>>>> <?php
>>>>>> $Tday = date( "m/d" ); // today
>>>>>> Is there some easy way to specify I want PST, in the date() call? I
>>>>>> can't seem to find any examples online.
>>>>> Place this as the first line:
>>>>> date_default_timezone_set("America/Los_Angeles");
>>>> I did - got:
>>>>
>>>> Fatal error: Call to undefined function: date_default_timezone_set() in
>>>> /nfs/cust/0/66/74/547660/web/NewStuff/M_Main/MainPage.php on line 5
>>>>
>>>> Any suggestions?
>>> What version of PHP is your server using?
>>> http://php.net/manual/en/function.date-default-timezone-set.php
>>> Says: (PHP 5 >= 5.1.0)
>>>
>>> Either that, or your path or syntax is incorrect.
>>>
>> How do I determine the version of php?
>
> The results of the phpinfo() function will tell you.
>

I did this (after several typos :>{ )

got back: "PHP Version 4.4.1"


...so, I guess it's not supported. Is there any way to specify PST in
the date request itself?

John Kopf

Jerry Stuckle

unread,
Jan 19, 2010, 4:35:34 PM1/19/10
to

You need to upgrade. PHP4.x has not been supported for years now.

Beauregard T. Shagnasty

unread,
Jan 19, 2010, 4:35:50 PM1/19/10
to
John O. Kopf wrote:

>>> Beauregard T. Shagnasty wrote:
>>>>>> Place this as the first line:
>>>>>> date_default_timezone_set("America/Los_Angeles");

>>> Says: (PHP 5 >= 5.1.0)

> [biggasnip]


> I did this (after several typos :>{ )
>
> got back: "PHP Version 4.4.1"
>
> ...so, I guess it's not supported. Is there any way to specify PST in
> the date request itself?

Do some math on the result you get?
Update your server to a modern version of PHP?

John O. Kopf

unread,
Jan 19, 2010, 7:18:41 PM1/19/10
to

Ihave no choice - the server and it's capabilities are *purchased* from
a vendor, who has control over what's there :>{

John Kopf

John O. Kopf

unread,
Jan 19, 2010, 7:19:57 PM1/19/10
to
Beauregard T. Shagnasty wrote:
> John O. Kopf wrote:
>
>>>> Beauregard T. Shagnasty wrote:
>>>>>>> Place this as the first line:
>>>>>>> date_default_timezone_set("America/Los_Angeles");
>>>> Says: (PHP 5 >= 5.1.0)
>> [biggasnip]
>> I did this (after several typos :>{ )
>>
>> got back: "PHP Version 4.4.1"
>>
>> ...so, I guess it's not supported. Is there any way to specify PST in
>> the date request itself?
>
> Do some math on the result you get?
> Update your server to a modern version of PHP?
>

Unfortunately, it's not "my" server - it's space purchased from an
outside party.

John Kopf

Doug Miller

unread,
Jan 19, 2010, 7:26:43 PM1/19/10
to
In article <hj5i4...@news1.newsguy.com>, "John O. Kopf" <ko...@att.net> wrote:
>
>Ihave no choice - the server and it's capabilities are *purchased* from
>a vendor, who has control over what's there :>{

Surely, you mean leased, not purchased -- if you purchased the server, then
you own it, and you can put whatever software on it you damn please.

Even if it's leased, though, you may still be able to use PHP 5. At least one
hosting company I know of has versions 3, 4, and 5 installed; by default, you
get version 4, but you can specify version 3 or 5 with a directive in
htaccess.

Jerry Stuckle

unread,
Jan 19, 2010, 7:47:52 PM1/19/10
to

If my vendor were so clueless that they are running something that much
out of date, I'd switch vendors IMMEDIATELY. Who knows what other
problems they might have?

I suggest you see if they don't have a supported version available - and
if not, find someone else - ASAP.

Beauregard T. Shagnasty

unread,
Jan 19, 2010, 10:20:45 PM1/19/10
to
John O. Kopf wrote:

As others said: get a better host.

You didn't respond to "Do some math on the result you get." Why don't
you just subtract three hours from the server's time?

matt

unread,
Jan 20, 2010, 9:07:55 AM1/20/10
to

Purchase your own server or move to a different outside party. Or at
least threaten to unless they upgrade PHP.

John O. Kopf

unread,
Jan 23, 2010, 5:36:49 PM1/23/10
to

That would involve a fairly complex calculation...

My keys are DATES (e.g., "07/04"), and the date function resolves the
occasional leap year; I can't just subtract 1 if the date comes back as
07/05 and it's between 2100 and 2400; that would screw up other things
like new years (12/31 - last day of the month) or 02/29 (Sadie Hawkins Day)

John Kopf

Beauregard T. Shagnasty

unread,
Jan 23, 2010, 7:54:31 PM1/23/10
to
John O. Kopf wrote:

> Beauregard T. Shagnasty wrote:
>> John O. Kopf wrote:
>>> Beauregard T. Shagnasty wrote:
>>>> John O. Kopf wrote:
>>>>>>> Beauregard T. Shagnasty wrote:
>>>>>>>>>> Place this as the first line:
>>>>>>>>>> date_default_timezone_set("America/Los_Angeles");
>>>>>

>>>>> ...so, I guess it's not supported. Is there any way to specify
>>>>> PST in the date request itself?
>>>>
>>>> Do some math on the result you get? Update your server to a modern
>>>> version of PHP?
>>

>> You didn't respond to "Do some math on the result you get." Why
>> don't you just subtract three hours from the server's time?
>
> That would involve a fairly complex calculation...

Complex? I don't think so.

> My keys are DATES (e.g., "07/04"), and the date function resolves the
> occasional leap year; I can't just subtract 1 if the date comes back
> as 07/05 and it's between 2100 and 2400; that would screw up other
> things like new years (12/31 - last day of the month) or 02/29 (Sadie
> Hawkins Day)

Huh?

You asked how you could change an Eastern Time Zone server's time to
Pacific Time. What's this stuff about leap year and Sadie Hawkins got
to do with subtracting 3 hours from server time?

You said, "...Unfortunately, even though we're located in California,


our Server is in EST; "

Have you never done date math?

$pacific = date("Y-m-d h:i:s", mktime(date("h")-3));
$pacifictime = date("h:i", mktime(date("h")-3));

// Or, if you want to format in the U.S. style:
$pacific = date("m/d", mktime(date("h")-3));

Doug Miller

unread,
Jan 23, 2010, 8:50:09 PM1/23/10
to
In article <hjftl...@news6.newsguy.com>, "John O. Kopf" <ko...@att.net> wrote:
>Beauregard T. Shagnasty wrote:
>> John O. Kopf wrote:
>>
>>> Beauregard T. Shagnasty wrote:
>>>> John O. Kopf wrote:
>>>>>>> Beauregard T. Shagnasty wrote:
>>>>>>>>>> Place this as the first line:
>>>>>>>>>> date_default_timezone_set("America/Los_Angeles");
>>>>>>> Says: (PHP 5 >= 5.1.0)
>>>>> [biggasnip]
>>>>> I did this (after several typos :>{ )
>>>>>
>>>>> got back: "PHP Version 4.4.1"
>>>>>
>>>>> ...so, I guess it's not supported. Is there any way to specify PST in
>>>>> the date request itself?
>>>> Do some math on the result you get?
>>>> Update your server to a modern version of PHP?
>>> Unfortunately, it's not "my" server - it's space purchased from an
>>> outside party.
>>
>> As others said: get a better host.
>>
>> You didn't respond to "Do some math on the result you get." Why don't
>> you just subtract three hours from the server's time?
>>
>
>That would involve a fairly complex calculation...

Subtracting three hours is "a fairly complex calculation" ???


>
>My keys are DATES (e.g., "07/04"), and the date function resolves the
>occasional leap year; I can't just subtract 1 if the date comes back as
>07/05 and it's between 2100 and 2400; that would screw up other things
>like new years (12/31 - last day of the month) or 02/29 (Sadie Hawkins Day)

You're waaaaaaaayyyyyyyy overthinking this.

John O. Kopf

unread,
Jan 25, 2010, 1:09:24 PM1/25/10
to

If you'd have been following this thread from the beginning, you'd
realize that your "solution" and rant are completely irrelevant.

Here again is the Problem:

A page will have occasional "obscure Holiday" images and captions
displayed. This can be implemente4d using either PHP or Java. I
decided that doing it in Java would require the client downloading the
entire table of holidays before anything could be displayed; so I chose
to implement it in PHP (Even here in Silicon Valley there are still a
large number of clients connecting through a dial-up modem, and the more
they have to download, the slower the page.)

To that end, I defined:
$Hday = array( );

...and then a number of entries; todays' is:
$Hday[ "01/25" ] = " 'RobertBurns.jpg', '173', '184', 'Happy (Robbie)
Burns Night' ";

...the bopy of the page contains:


<?php
$Tday = date( "m/d" ); // today

if ( isset( $Hday[ $Tday ] ) )
{
$Event = $Hday[ $Tday ];
echo( "<script><!--\n" );
echo( " HolidayBlock( " . $Event . ")\n" );
echo( "--></script>\n" );
}
?>

...this all works fine (You can go to http://www.scvcma.org/ to see the
result).


THE PROBLEM
... is that 'date( "m/d" )' returns the value for the SERVER (which
happens to be located in New Jersey, and thus returns based upon EST).
That means the a CLIENT in California (using PST) will see the result of
$Tday rolling over to the next date at 9PM PST.

Thus, the correction of SERVER time to Client time *is* complex, since
the SERVER has no knowledge of the CLIENT's time zone.

SO, if no one can identify a way for the SERVER to perform the
correction, I see no solution but for the SERVER to download any $Event
for $Tday, as well as any for the day preceding and following, as a
truncatged table (at most 3 entries), and then have Java code on the
CLIENT use the truncated table to set the display for the CLIENT's time
zone.

John Kopf

Beauregard T. Shagnasty

unread,
Jan 25, 2010, 2:08:30 PM1/25/10
to
John O. Kopf wrote:

> Beauregard T. Shagnasty wrote:
>> // Or, if you want to format in the U.S. style:
>> $pacific = date("m/d", mktime(date("h")-3));
>
> If you'd have been following this thread from the beginning, you'd
> realize that your "solution" and rant are completely irrelevant.

Not so, me bucko. ("Rant?" I prefer "succinct.")



> Here again is the Problem:
>

> A page will have occasional "obscure Holiday" images and captions ..


> ...the bopy of the page contains:
> <?php
> $Tday = date( "m/d" ); // today

Repeating (with your variable, instead of $pacific):
$Tday = date("m/d", mktime(date("h")-3)); // today in Pacific time

> THE PROBLEM
> ... is that 'date( "m/d" )' returns the value for the SERVER

UNLESS of course you SUBTRACT the three hours I've been trying to tell
you about...

> happens to be located in New Jersey, and thus returns based upon EST).
> That means the a CLIENT in California (using PST) will see the result of
> $Tday rolling over to the next date at 9PM PST.

No, they won't.

I'm sorry you can't see the simple result. If this above doesn't do it
for you, you're own your own.

Curtis Dyer

unread,
Jan 25, 2010, 6:04:19 PM1/25/10
to
On 25 Jan 2010, "Beauregard T. Shagnasty"
<a.non...@example.invalid> wrote:

> John O. Kopf wrote:
>
>> Beauregard T. Shagnasty wrote:

<snip>

>> Here again is the Problem:
>>
>> A page will have occasional "obscure Holiday" images and
>> captions .. ...the bopy of the page contains:
>> <?php
>> $Tday = date( "m/d" ); // today
>
> Repeating (with your variable, instead of $pacific):
> $Tday = date("m/d", mktime(date("h")-3)); // today in Pacific
> time

You need to use `date('H')', otherwise 1pm EST, for example, will
incorrectly yield yesterday's date. In any case, it's probably
easier to use strtotime():

$tz = 'PST';

/* calculates current timestamp in PST */
$today = date('m/d', strtotime($tz));

If using a numeric offset for the timezone, it'd be more portable
to use `gmdate()' to calculate the timezone offsets with respect
to GMT:

$pst = '-8'; /* PST */
$cet = '+1'; /* CET */

echo gmdate('m/d H:i', strtotime("$pst hours")), "\n";
echo gmdate('m/d H:i', strtotime("$cet hours"));

Both approaches should yield the same results, regardless of the
server's locale.

<snip>

--
Curtis Dyer
<? $x='<? $x=%c%s%c;printf($x,39,$x,39);?>';printf($x,39,$x,39);?>

Beauregard T. Shagnasty

unread,
Jan 25, 2010, 11:32:02 PM1/25/10
to
Curtis Dyer wrote:

> You need to use `date('H')', otherwise 1pm EST, for example, will
> incorrectly yield yesterday's date.

Yes, I forgot the 12/24 parameters.

> In any case, it's probably easier to use strtotime():

There are many ways to skin the datetime cat. :-)

0 new messages