Connecting Tech Pros Worldwide Forums | Help | Site Map

Date time stamp help

Dave
Guest
 
Posts: n/a
#1: Jul 17 '05
Hey folks,

I'm moving from ASP to PHP and I must say that on using this for only a day
it is MUCH simpler to get things going. Already have made a VERY basic blog
site for myself in a very short period of time. Anyhow I have a datetime
issue:

On my blog site I capture the date like this: $date=date("Y-m-d g-i-s");

When I display this date later it is 2 hours being my time. I'm guessing
that the servers are somewhere in the mid west - I am in the EST time zone.
Can anyone help me correct this so that I either capture the time proplerly
or display it in my zone?

Thanks,
Dave



David Gillen
Guest
 
Posts: n/a
#2: Jul 17 '05

re: Date time stamp help


An noise sounding like Dave said:[color=blue]
> Hey folks,
>
> I'm moving from ASP to PHP and I must say that on using this for only a day
> it is MUCH simpler to get things going. Already have made a VERY basic blog
> site for myself in a very short period of time. Anyhow I have a datetime
> issue:
>
> On my blog site I capture the date like this: $date=date("Y-m-d g-i-s");
>[/color]
$date = date("Y-m-d ").(date('g')-2).date('-i-s');
Don't you just love dirty hacks.


[color=blue]
> When I display this date later it is 2 hours being my time. I'm guessing
> that the servers are somewhere in the mid west - I am in the EST time zone.
> Can anyone help me correct this so that I either capture the time proplerly
> or display it in my zone?
>
> Thanks,
> Dave
>
>[/color]


--

/(bb|[^b]{2})/
Trees with square roots don't have very natural logs.

Chung Leong
Guest
 
Posts: n/a
#3: Jul 17 '05

re: Date time stamp help



"Dave" <overkil6@cogeco.ca> wrote in message
news:QuLOd.21758$m22.8552@read1.cgocable.net...[color=blue]
> Hey folks,
>
> I'm moving from ASP to PHP and I must say that on using this for only a[/color]
day[color=blue]
> it is MUCH simpler to get things going. Already have made a VERY basic[/color]
blog[color=blue]
> site for myself in a very short period of time. Anyhow I have a datetime
> issue:
>
> On my blog site I capture the date like this: $date=date("Y-m-d g-i-s");
>
> When I display this date later it is 2 hours being my time. I'm guessing
> that the servers are somewhere in the mid west - I am in the EST time[/color]
zone.[color=blue]
> Can anyone help me correct this so that I either capture the time[/color]
proplerly[color=blue]
> or display it in my zone?
>
> Thanks,
> Dave
>
>[/color]

$date=date("Y-m-d g-i-s", time() + 120);




--
Project Wapache - http://wapache.sourceforge.net


michelle
Guest
 
Posts: n/a
#4: Jul 17 '05

re: Date time stamp help


Dave wrote:[color=blue]
> Hey folks,
>
> I'm moving from ASP to PHP and I must say that on using this for only a day
> it is MUCH simpler to get things going. Already have made a VERY basic blog
> site for myself in a very short period of time. Anyhow I have a datetime
> issue:
>
> On my blog site I capture the date like this: $date=date("Y-m-d g-i-s");
>
> When I display this date later it is 2 hours being my time. I'm guessing
> that the servers are somewhere in the mid west - I am in the EST time zone.
> Can anyone help me correct this so that I either capture the time proplerly
> or display it in my zone?
>
> Thanks,
> Dave
>
>[/color]
Dave,

This code also accounts for daylight savings time for my time offset
which is -8 (Pacific):

echo gmdate('Y-m-d g:i s', time() + 3600*(-8 + date('I')))

Why change your code twice a year?

Miki
Dave
Guest
 
Posts: n/a
#5: Jul 17 '05

re: Date time stamp help


Well if the time is being captured on the server side and I'm adding 2 hours
to that in my code - how would day light savings come into play?

"michelle" <miki@spam_me.net> wrote in message
news:hbadnY9xCr-S65HfRVn-oQ@comcast.com...[color=blue]
> Dave wrote:[color=green]
>> Hey folks,
>>
>> I'm moving from ASP to PHP and I must say that on using this for only a
>> day it is MUCH simpler to get things going. Already have made a VERY
>> basic blog site for myself in a very short period of time. Anyhow I have
>> a datetime issue:
>>
>> On my blog site I capture the date like this: $date=date("Y-m-d g-i-s");
>>
>> When I display this date later it is 2 hours being my time. I'm guessing
>> that the servers are somewhere in the mid west - I am in the EST time
>> zone. Can anyone help me correct this so that I either capture the time
>> proplerly or display it in my zone?
>>
>> Thanks,
>> Dave[/color]
> Dave,
>
> This code also accounts for daylight savings time for my time offset which
> is -8 (Pacific):
>
> echo gmdate('Y-m-d g:i s', time() + 3600*(-8 + date('I')))
>
> Why change your code twice a year?
>
> Miki[/color]


michelle
Guest
 
Posts: n/a
#6: Jul 17 '05

re: Date time stamp help


Dave wrote:[color=blue]
> Well if the time is being captured on the server side and I'm adding 2 hours
> to that in my code - how would day light savings come into play?
>
> "michelle" <miki@spam_me.net> wrote in message
> news:hbadnY9xCr-S65HfRVn-oQ@comcast.com...
>[color=green]
>>Dave wrote:
>>[color=darkred]
>>>Hey folks,
>>>
>>>I'm moving from ASP to PHP and I must say that on using this for only a
>>>day it is MUCH simpler to get things going. Already have made a VERY
>>>basic blog site for myself in a very short period of time. Anyhow I have
>>>a datetime issue:
>>>
>>>On my blog site I capture the date like this: $date=date("Y-m-d g-i-s");
>>>
>>>When I display this date later it is 2 hours being my time. I'm guessing
>>>that the servers are somewhere in the mid west - I am in the EST time
>>>zone. Can anyone help me correct this so that I either capture the time
>>>proplerly or display it in my zone?
>>>
>>>Thanks,
>>>Dave[/color]
>>
>>Dave,
>>
>>This code also accounts for daylight savings time for my time offset which
>>is -8 (Pacific):
>>
>>echo gmdate('Y-m-d g:i s', time() + 3600*(-8 + date('I')))
>>
>>Why change your code twice a year?
>>
>>Miki[/color]
>
>
>[/color]
The safest way to do this is to use the gmdate() function, which doesn't
take into account daylight savings time...it is simply GMT. You can
do it your way if you are positive that your server will not move. But
my suggestion will make your code more portable - if you move it to
another server. If you do move to another server in another time zone
you will have to rewrite this portion of code...and if you use this
thinking throughout your work there will be more changes, too. The way I
suggest is a simple set it and forget it method...but you can do it your
way if you like.

Miki
Tim Roberts
Guest
 
Posts: n/a
#7: Jul 17 '05

re: Date time stamp help


"Dave" <overkil6@cogeco.ca> wrote:[color=blue]
>
>Well if the time is being captured on the server side and I'm adding 2 hours
>to that in my code - how would day light savings come into play?[/color]

Your domain is in Canada. In Canada, all of the time zones enter and exit
daylight savings time at the same time. Thus, when YOU go into DST, your
server will also have gone into DST.
--
- Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
Closed Thread