473,387 Members | 1,859 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,387 software developers and data experts.

newbee stupid question regarding $initstartdate = date("d-m-Y");

Hi there

I have

$initstartdate = date("d-m-Y");

in my code

How can I get it to be date() + 1 or 7 for that matter. Because my server is in the US and I am in New Zealand, they are always a
day behind....

I have looked at php.net, I just could not work it out ...

Thank you

- Nicolaas
Jul 23 '05 #1
16 2053
sorry this one was supposed to go to php group ...
Hi there

I have

$initstartdate = date("d-m-Y");

in my code

How can I get it to be date() + 1 or 7 for that matter. Because my server is in the US and I am in New Zealand, they are always a
day behind....

I have looked at php.net, I just could not work it out ...

Thank you

- Nicolaas


Jul 23 '05 #2
On Sun, 30 Jan 2005 16:10:12 +1300 WindAndWaves wrote:
sorry this one was supposed to go to php group ...
Hi there I have $initstartdate = date("d-m-Y"); in my code How can I get it to be date() + 1 or 7 for that matter. Because my
server is in the US and I am in New Zealand, they are always a
day behind.... I have looked at php.net, I just could not work it out ... Thank you - Nicolaas


While you're working on the script, set your clock to a US time zone.
If you add anything to YOUR script, then those in the US would see it wrong.


Jul 23 '05 #3

"Richard" <An*******@127.001> wrote in message news:ct*********@news2.newsguy.com...
On Sun, 30 Jan 2005 16:10:12 +1300 WindAndWaves wrote:
sorry this one was supposed to go to php group ...


Hi there

I have

$initstartdate = date("d-m-Y");

in my code

How can I get it to be date() + 1 or 7 for that matter. Because my
server is in the US and I am in New Zealand, they are always a
day behind....

I have looked at php.net, I just could not work it out ...

Thank you

- Nicolaas


While you're working on the script, set your clock to a US time zone.
If you add anything to YOUR script, then those in the US would see it wrong.


Well, Richard, we are in New Zealand and not in the US. We also format the date as mm-dd-yyyy. Furthermore, it is OK to be one day
ahead - it makes sense in context (hotel booking service), but one day in the past looks stupid.

Is there an alternative answer?

Thank you for your reply.

- Nicolaas
Jul 23 '05 #4
On Sun, 30 Jan 2005 17:09:57 +1300 WindAndWaves wrote:

"Richard" <An*******@127.001> wrote in message
news:ct*********@news2.newsguy.com...
On Sun, 30 Jan 2005 16:10:12 +1300 WindAndWaves wrote:
> sorry this one was supposed to go to php group ...
> Hi there > I have > $initstartdate = date("d-m-Y"); > in my code > How can I get it to be date() + 1 or 7 for that matter. Because my
> server is in the US and I am in New Zealand, they are always a
> day behind.... > I have looked at php.net, I just could not work it out ... > Thank you > - Nicolaas
While you're working on the script, set your clock to a US time zone.
If you add anything to YOUR script, then those in the US would see it
wrong.

Well, Richard, we are in New Zealand and not in the US. We also format
the date as mm-dd-yyyy. Furthermore, it is OK to be one day
ahead - it makes sense in context (hotel booking service), but one day
in the past looks stupid. Is there an alternative answer? Thank you for your reply. - Nicolaas

Set it to GMT????

Jul 23 '05 #5
WindAndWaves wrote:
"Richard" <An*******@127.001> wrote in message news:ct*********@news2.newsguy.com...
On Sun, 30 Jan 2005 16:10:12 +1300 WindAndWaves wrote:

sorry this one was supposed to go to php group ...


Hi there

I have

$initstartdate = date("d-m-Y");

in my code

How can I get it to be date() + 1 or 7 for that matter. Because my
server is in the US and I am in New Zealand, they are always a
day behind....

I have looked at php.net, I just could not work it out ...

Thank you

- Nicolaas


While you're working on the script, set your clock to a US time zone.
If you add anything to YOUR script, then those in the US would see it wrong.

Well, Richard, we are in New Zealand and not in the US. We also format the date as mm-dd-yyyy. Furthermore, it is OK to be one day
ahead - it makes sense in context (hotel booking service), but one day in the past looks stupid.

Is there an alternative answer?

Thank you for your reply.

- Nicolaas

So am I and I bl**dy don't. Nor does anyone else I know. dd/mm/yyyy.
However, I agree with the arrogance of any poster demanding we use an US TZ!

To answer the problem that you've got requires javascript to be run on
the client machine to get the time offset. Once you've got that, then
you can offset by using putenv ("TZ=$timezone") to modify the server
timezone to the same value.

That's how I've done it in the past. I save all datestamps in Mysql as
UTC to make life easier as well.
Steve
Proudly GMT+13.
Jul 23 '05 #6
I noticed that Message-ID: <ct**********@lust.ihug.co.nz> from Steve
contained the following:
To answer the problem that you've got requires javascript to be run on
the client machine to get the time offset. Once you've got that, then
you can offset by using putenv ("TZ=$timezone") to modify the server
timezone to the same value.

That's how I've done it in the past. I save all datestamps in Mysql as
UTC to make life easier as well.


The OP just wants to offset the date by a fixed amount to compensate for
the fact that the server is in the States. So he could either add a
known number of seconds to time() or use strtotime()

$timestamp=strtotime(+n hours); //where n is the time difference

$initstartdate = date("d-m-Y",$timestamp);

Not sure how daylight saving would affect that though.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 23 '05 #7

"Geoff Berrow" <bl******@ckdog.co.uk> wrote in message news:4q********************************@4ax.com...
I noticed that Message-ID: <ct**********@lust.ihug.co.nz> from Steve
contained the following:
To answer the problem that you've got requires javascript to be run on
the client machine to get the time offset. Once you've got that, then
you can offset by using putenv ("TZ=$timezone") to modify the server
timezone to the same value.

That's how I've done it in the past. I save all datestamps in Mysql as
UTC to make life easier as well.


The OP just wants to offset the date by a fixed amount to compensate for
the fact that the server is in the States. So he could either add a
known number of seconds to time() or use strtotime()

$timestamp=strtotime(+n hours); //where n is the time difference

$initstartdate = date("d-m-Y",$timestamp);

Not sure how daylight saving would affect that though.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/


Hi Guys

Lets not get too pedantic here. I like this timestamp thing, I will just add a couple of hours. In the exciting world of travel
hours a pretty messy anyway and all I wanted to do is to have a feasible start date for a trip (they can change it themselves if
they want to...).

Thanks for all your interesting answers I will

Nicolaas +as many as possible

PS la luche sigue....
Jul 23 '05 #8
I noticed that Message-ID: <bU*********************@news.xtra.co.nz>
from WindAndWaves contained the following:
I like this timestamp thing, I will just add a couple of hours. In the exciting world of travel
hours a pretty messy anyway and all I wanted to do is to have a feasible start date for a trip (they can change it themselves if
they want to...).


Pragmatism. I like that. :-)

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 23 '05 #9
On Sun, 30 Jan 2005 10:20:04 +0000, Geoff Berrow
<bl******@ckdog.co.uk> reverently intoned upon the aether:
I noticed that Message-ID: <ct**********@lust.ihug.co.nz> from Steve
contained the following:
To answer the problem that you've got requires javascript to be run on
the client machine to get the time offset. Once you've got that, then
you can offset by using putenv ("TZ=$timezone") to modify the server
timezone to the same value.

That's how I've done it in the past. I save all datestamps in Mysql as
UTC to make life easier as well.


The OP just wants to offset the date by a fixed amount to compensate for
the fact that the server is in the States. So he could either add a
known number of seconds to time() or use strtotime()

$timestamp=strtotime(+n hours); //where n is the time difference

$initstartdate = date("d-m-Y",$timestamp);

Not sure how daylight saving would affect that though.


DST should not affect time() which is measured in seconds since the
Unix epoch. I have not researched this too far since I use servers in
Arizona where DST is never observed (the time is constant). But if
one just used time() and adds hours_offset*3600 to time it will solve
the problem. I would suspect that DST affects date() though.

Also, to a prior poster, Javascript is a poor choice as the
application should no the time zone of each hotel, hence the offset
should be known by the server for each hotel which appears to be only
two time zone for New Zealand.

from: http://www.statoids.com/tnz.html
UTC+12:oo for NZST
UTC+12:45 for CHAST (the Chatham Islands)

From the first Sunday in October to the third Sunday in March
UTC+13:oo for NZDT
UTC+13:45 for CHADT

That said, there is plenty of discussion in the PHP manual if you read
the user comments.

http://us3.php.net/manual/en/function.date.php

And of course one should test one's server and check with the system
administrators to get their time maintenance policy.

enjoy,

Sean

"In the End, we will remember not the words of our enemies,
but the silence of our friends."

- Martin Luther King Jr. (1929-1968)

Photo Archive @ http://www.tearnet.com/Sean
Last Updated 29 Sept. 2004
Jul 23 '05 #10
Sean wrote:
On Sun, 30 Jan 2005 10:20:04 +0000, Geoff Berrow
<bl******@ckdog.co.uk> reverently intoned upon the aether:

I noticed that Message-ID: <ct**********@lust.ihug.co.nz> from Steve
contained the following:

To answer the problem that you've got requires javascript to be run on
the client machine to get the time offset. Once you've got that, then
you can offset by using putenv ("TZ=$timezone") to modify the server
timezone to the same value.

That's how I've done it in the past. I save all datestamps in Mysql as
UTC to make life easier as well.
The OP just wants to offset the date by a fixed amount to compensate for
the fact that the server is in the States. So he could either add a
known number of seconds to time() or use strtotime()

$timestamp=strtotime(+n hours); //where n is the time difference

$initstartdate = date("d-m-Y",$timestamp);

Not sure how daylight saving would affect that though.

DST should not affect time() which is measured in seconds since the
Unix epoch. I have not researched this too far since I use servers in
Arizona where DST is never observed (the time is constant). But if
one just used time() and adds hours_offset*3600 to time it will solve
the problem. I would suspect that DST affects date() though.

Also, to a prior poster, Javascript is a poor choice as the
application should no the time zone of each hotel, hence the offset
should be known by the server for each hotel which appears to be only
two time zone for New Zealand.

Well, if you can suggest another client side language that can pick up
the info, then let me know.

What if you're browsing the website from Peru, for example. All the
times will be wrong.
from: http://www.statoids.com/tnz.html
UTC+12:oo for NZST
UTC+12:45 for CHAST (the Chatham Islands)

From the first Sunday in October to the third Sunday in March
UTC+13:oo for NZDT
UTC+13:45 for CHADT

That said, there is plenty of discussion in the PHP manual if you read
the user comments.

http://us3.php.net/manual/en/function.date.php

And of course one should test one's server and check with the system
administrators to get their time maintenance policy.

enjoy,

Sean

"In the End, we will remember not the words of our enemies,
but the silence of our friends."

- Martin Luther King Jr. (1929-1968)

Photo Archive @ http://www.tearnet.com/Sean
Last Updated 29 Sept. 2004

Jul 23 '05 #11
On Mon, 31 Jan 2005 06:14:02 +1300, Steve <Th*****@Aint.valid>
reverently intoned upon the aether:
Well, if you can suggest another client side language that can pick up
the info, then let me know.
This is not my issue. My issue is the use of local time when the time
at the destination is the time that fits the problem domain.
What if you're browsing the website from Peru, for example. All the
times will be wrong.


For a hotel reservation at a hotel in New Zealand? I have never heard
of making a hotel reservation in anything but the local time of the
hotel. I am almost certain a hotel clerk in Auckland could care less
what time it is in Peru.

This is not to say using Javascript to localize displayed times in
another application is not a good idea, it just makes no sense to me
in this application.

enjoy,

Sean
"In the End, we will remember not the words of our enemies,
but the silence of our friends."

- Martin Luther King Jr. (1929-1968)

Photo Archive @ http://www.tearnet.com/Sean
Last Updated 29 Sept. 2004
Jul 23 '05 #12

"Sean" <sd************@REMOVEhotmail.com> wrote in message news:cl********************************@4ax.com...

.....
Also, to a prior poster, Javascript is a poor choice as the
application should no the time zone of each hotel, hence the offset
should be known by the server for each hotel which appears to be only
two time zone for New Zealand.


Javascript is a nightmare when it comes to getting the time right, because it is client side and who knows what those clients do
with their clocks. Mine, for example, seems to be out of sink regularly.....

Anyway, most people know what time it is at their place, they would rather know what time it is somewhere else ;-)

Nicolaas
Jul 23 '05 #13
JRS: In article <4q********************************@4ax.com>, dated
Sun, 30 Jan 2005 10:20:04, seen in news:comp.lang.javascript, Geoff
Berrow <bl******@ckdog.co.uk> posted :
I noticed that Message-ID: <ct**********@lust.ihug.co.nz> from Steve
contained the following:
To answer the problem that you've got requires javascript to be run on
the client machine to get the time offset. Once you've got that, then
you can offset by using putenv ("TZ=$timezone") to modify the server
timezone to the same value.

That's how I've done it in the past. I save all datestamps in Mysql as
UTC to make life easier as well.


The OP just wants to offset the date by a fixed amount to compensate for
the fact that the server is in the States. So he could either add a
known number of seconds to time() or use strtotime()

$timestamp=strtotime(+n hours); //where n is the time difference

$initstartdate = date("d-m-Y",$timestamp);

Not sure how daylight saving would affect that though.


As long as you allow "fixed" to mean "changes at least twice a year, and
possibly four times", you see no problem.

The server should be serving time in GMT; to suit the local natives'
whims, it may also serve native civil time. But one should only get GMT
or UTC from a server (UK servers probably serve UTC illegally).

If the OP's users want their local time, their machines can tell them
that, if properly set, which is their responsibility.

If it is necessary to relate civil time at places remote from the user
to UTC, then it is necessary to know the Time Zone and Summer Time Rules
for each remote place, which can be expressed as a TZ string (that may
rule out Israel; JJC?). Then, by careful reading of the FAQ of this
newsgroup, one can see how to convert UTC into remote civil time.

The OP's question is not well expressed; but offsetting a date/time by a
given amount of absolute or civil time is not difficult in javascript,
though frequently done wrongly.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #14
On Mon, 31 Jan 2005 08:42:07 +1300, "WindAndWaves" <ac****@ngaru.com>
reverently intoned upon the aether:

"Sean" <sd************@REMOVEhotmail.com> wrote in message news:cl********************************@4ax.com...

....
Also, to a prior poster, Javascript is a poor choice as the
application should no the time zone of each hotel, hence the offset
should be known by the server for each hotel which appears to be only
two time zone for New Zealand.


Javascript is a nightmare when it comes to getting the time right, because
it is client side and who knows what those clients do
with their clocks. Mine, for example, seems to be out of sink regularly.....

Anyway, most people know what time it is at their place, they would
rather know what time it is somewhere else ;-)


:o)

I agree. Like what time it is at home with your feet up and resting
rather than what time it is at work. ;o)

As for time accuracy, if you run Windows XP, go to Start->Control
Panel and double click "date and time".

Next, go to the "Time Zone" tab and ensure that the checkbox for
"Automatically adjust clock for daylight saving changes" is checked
and that you have the proper time zone selected.

Next, go the "Internet Time" tab and ensure that the checkbox for
"Automatically synchronize with an Internet time server" is checked.
Pick your favorite time server from the drop down list.

Next, forget about keeping the clock on your PC in sync, it will take
care of itself and should remain accurate within a minute or so.

enjoy,

Sean
"In the End, we will remember not the words of our enemies,
but the silence of our friends."

- Martin Luther King Jr. (1929-1968)

Photo Archive @ http://www.tearnet.com/Sean
Last Updated 29 Sept. 2004
Jul 23 '05 #15
Sean wrote:
On Mon, 31 Jan 2005 06:14:02 +1300, Steve <Th*****@Aint.valid>
reverently intoned upon the aether:

Well, if you can suggest another client side language that can pick up
the info, then let me know.

This is not my issue. My issue is the use of local time when the time
at the destination is the time that fits the problem domain.

What if you're browsing the website from Peru, for example. All the
times will be wrong.

For a hotel reservation at a hotel in New Zealand? I have never heard
of making a hotel reservation in anything but the local time of the
hotel. I am almost certain a hotel clerk in Auckland could care less
what time it is in Peru.

This is not to say using Javascript to localize displayed times in
another application is not a good idea, it just makes no sense to me
in this application.

enjoy,

Sean

Hi Sean,

Sorry about that. My newsreader has chopped off the start of the thread.
In that case, storing the timezone in the database along with the
location is the simplest way of doing it. Then you can enforce that
timezone on the server using the method I suggested earlier.

It works... honest

Steve
"In the End, we will remember not the words of our enemies,
but the silence of our friends."

- Martin Luther King Jr. (1929-1968)

Photo Archive @ http://www.tearnet.com/Sean
Last Updated 29 Sept. 2004

Jul 23 '05 #16
On Mon, 31 Jan 2005 18:24:00 +1300, Steve <Th*****@Aint.valid>
reverently intoned upon the aether:

Sorry about that. My newsreader has chopped off the start of the thread.
In that case, storing the timezone in the database along with the
location is the simplest way of doing it. Then you can enforce that
timezone on the server using the method I suggested earlier.

It works... honest

Steve


I believe you. As for sorry, now worries. This is Usenet after all
and if my skin is not thick enough to survive, then that is my
problem. :o) I also have excellent completion on my Usenet server so
I miss little.

I think Javascript has its place, put the value in UTC or GMT by
default and then use Javascript to localize it if Javascript is
enabled. But one cannot depend of Javascript being enable, hence I
favor localizing the time server side if possible. If not, then make
it generic (UTC/GMT) and then localize client side.

all the best,

Sean
"In the End, we will remember not the words of our enemies,
but the silence of our friends."

- Martin Luther King Jr. (1929-1968)

Photo Archive @ http://www.tearnet.com/Sean
Last Updated 29 Sept. 2004
Jul 23 '05 #17

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

Similar topics

7
by: Martin Feuersteiner | last post by:
Hi! I would be grateful for any advise regarding what I'm doing wrong.. My brain is stuck. Probably some stupid simple mistake I don't see. Thanks very much for your efforts! Martin I have...
1
by: Claude Vernier | last post by:
Hi, I already got a nice Web application running and need to adapt it for iPaqs, Smartphone and Blackberry. Can you suggest a better newsgroup if any and some links to find best practices and...
2
by: Newbee Adam | last post by:
some said that .NET app can run on any program where rutime exists. What is "runtime" in this sense? will I have to install runtime or .net framework or .NET support on an xp machine for a...
119
by: rhat | last post by:
I heard that beta 2 now makes ASP.NET xhtml compliant. Can anyone shed some light on what this will change and it will break stuff as converting HTML to XHTML pages DO break things. see,...
2
by: Newbee Adam | last post by:
is it stored in a directory on hard drive, if so where? -- Adam S
2
by: Visual Systems AB \(Martin Arvidsson\) | last post by:
Hi! I was testing an application that is writing a mail and sends it to a recieptiens. I then came across a couple of ??? in my head, coul anyone briefly tell me what the difference is between...
1
by: Visual Systems AB \(Martin Arvidsson\) | last post by:
Hi all! Sorry if this is the wrong NG for this type of Q. On my .aspx page i have a TextControl and a button. When i press the button, i want to insert the changes to my SQL database how do...
1
by: Visual Systems AB \(Martin Arvidsson\) | last post by:
Hi all! Sorry if this is the wrong NG for this type of Q. On my .aspx page i have a TextControl and a button. When i press the button, i want to insert the changes to my SQL database how do...
2
by: Rene | last post by:
Hello to all! I am a newbee to C++, I did a beginners' course, and now I am stuck with a strange problem. I have written the function that is pasted downwards. The peculiar thing is that when...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.