473,405 Members | 2,344 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.

how can I use getdate(...) excluding TZ.


Hi,

My timezone is GMT +2
So when I do a
$date = getdate( 0 );

I get:

$date =
{
['seconds'] (integer) = 0
['minutes'] (integer) = 0
['hours'] (integer) = 2 //<-- Hour is not 0 but +2
['mday'] (integer) = 1
['wday'] (integer) = 4
['mon'] (integer) = 1
['year'] (integer) = 1970
['yday'] (integer) = 0
['weekday'] (string) = "Thursday"
['month'] (string) = "January"
['0'] (integer) = 0
}

I cannot do:
$date = getdate( 0 - (2*3600) );
as negative numbers are not accepted, (on the window server).

So how can I do getdate( 0 ) and return the value without it been
converted by the server TZ.
Using setlocal(...) is also a bit of a Hacky kind of way of doing
things.

FFMG
--

'webmaster forum' (http://www.httppoint.com) | 'webmaster Directory'
(http://www.webhostshunter.com/) | 'Recreation Vehicle insurance'
(http://www.insurance-owl.com/other/car_rec.php)
'Free URL redirection service' (http://urlkick.com/)
------------------------------------------------------------------------
FFMG's Profile: http://www.httppoint.com/member.php?userid=580
View this thread: http://www.httppoint.com/showthread.php?t=14320

Message Posted via the webmaster forum http://www.httppoint.com, (Ad revenue sharing).

May 2 '07 #1
6 2423
On May 2, 9:03 am, FFMG <FFMG.2py...@no-mx.httppoint.comwrote:
Hi,

My timezone is GMT +2
So when I do a
$date = getdate( 0 );

I get:

$date =
{
['seconds'] (integer) = 0
['minutes'] (integer) = 0
['hours'] (integer) = 2 //<-- Hour is not 0 but +2
['mday'] (integer) = 1
['wday'] (integer) = 4
['mon'] (integer) = 1
['year'] (integer) = 1970
['yday'] (integer) = 0
['weekday'] (string) = "Thursday"
['month'] (string) = "January"
['0'] (integer) = 0

}

I cannot do:
$date = getdate( 0 - (2*3600) );
as negative numbers are not accepted, (on the window server).

So how can I do getdate( 0 ) and return the value without it been
converted by the server TZ.
Using setlocal(...) is also a bit of a Hacky kind of way of doing
things.

FFMG

--

'webmaster forum' (http://www.httppoint.com) | 'webmaster Directory'
(http://www.webhostshunter.com/) | 'Recreation Vehicle insurance'
(http://www.insurance-owl.com/other/car_rec.php)
'Free URL redirection service' (http://urlkick.com/)
------------------------------------------------------------------------
FFMG's Profile:http://www.httppoint.com/member.php?userid=580
View this thread:http://www.httppoint.com/showthread.php?t=14320

Message Posted via the webmaster forumhttp://www.httppoint.com, (Ad revenue sharing).
getdate(time() - (2*3600)) perhaps?

May 2 '07 #2
On May 2, 3:03 am, FFMG <FFMG.2py...@no-mx.httppoint.comwrote:
Hi,

My timezone is GMT +2
So when I do a
$date = getdate( 0 );

I get:

$date =
{
['seconds'] (integer) = 0
['minutes'] (integer) = 0
['hours'] (integer) = 2 //<-- Hour is not 0 but +2
['mday'] (integer) = 1
['wday'] (integer) = 4
['mon'] (integer) = 1
['year'] (integer) = 1970
['yday'] (integer) = 0
['weekday'] (string) = "Thursday"
['month'] (string) = "January"
['0'] (integer) = 0

}

I cannot do:
$date = getdate( 0 - (2*3600) );
as negative numbers are not accepted, (on the window server).

So how can I do getdate( 0 ) and return the value without it been
converted by the server TZ.
Using setlocal(...) is also a bit of a Hacky kind of way of doing
things.

FFMG

--

'webmaster forum' (http://www.httppoint.com) | 'webmaster Directory'
(http://www.webhostshunter.com/) | 'Recreation Vehicle insurance'
(http://www.insurance-owl.com/other/car_rec.php)
'Free URL redirection service' (http://urlkick.com/)
------------------------------------------------------------------------
FFMG's Profile:http://www.httppoint.com/member.php?userid=580
View this thread:http://www.httppoint.com/showthread.php?t=14320

Message Posted via the webmaster forumhttp://www.httppoint.com, (Ad revenue sharing).
Timestamps don't have a time zone -- they're always in GMT. So, when
you say a timestamp of zero, that's Jan 1, 1970 0:00 GMT -- which,
because your GMT offset is +2, is really Jan 1, 1970 02:00 in your
timezone.

What is it that you're trying to accomplish? Do you want the
timestamp for midnight on Jan 1, 1970 in /your/ timezone? Try this:

strtotime('Jan 1 2007');

May 2 '07 #3
On May 2, 9:26 am, ZeldorBlat <zeldorb...@gmail.comwrote:
On May 2, 3:03 am, FFMG <FFMG.2py...@no-mx.httppoint.comwrote:
Hi,
My timezone is GMT +2
So when I do a
$date = getdate( 0 );
I get:
$date =
{
['seconds'] (integer) = 0
['minutes'] (integer) = 0
['hours'] (integer) = 2 //<-- Hour is not 0 but +2
['mday'] (integer) = 1
['wday'] (integer) = 4
['mon'] (integer) = 1
['year'] (integer) = 1970
['yday'] (integer) = 0
['weekday'] (string) = "Thursday"
['month'] (string) = "January"
['0'] (integer) = 0
}
I cannot do:
$date = getdate( 0 - (2*3600) );
as negative numbers are not accepted, (on the window server).
So how can I do getdate( 0 ) and return the value without it been
converted by the server TZ.
Using setlocal(...) is also a bit of a Hacky kind of way of doing
things.
FFMG
--
'webmaster forum' (http://www.httppoint.com) | 'webmaster Directory'
(http://www.webhostshunter.com/) | 'Recreation Vehicle insurance'
(http://www.insurance-owl.com/other/car_rec.php)
'Free URL redirection service' (http://urlkick.com/)
------------------------------------------------------------------------
FFMG's Profile:http://www.httppoint.com/member.php?userid=580
View this thread:http://www.httppoint.com/showthread.php?t=14320
Message Posted via the webmaster forumhttp://www.httppoint.com, (Ad revenue sharing).

Timestamps don't have a time zone -- they're always in GMT. So, when
you say a timestamp of zero, that's Jan 1, 1970 0:00 GMT -- which,
because your GMT offset is +2, is really Jan 1, 1970 02:00 in your
timezone.

What is it that you're trying to accomplish? Do you want the
timestamp for midnight on Jan 1, 1970 in /your/ timezone? Try this:

strtotime('Jan 1 2007');
Ooops -- should have been:

strtotime('Jan 1 1970');

May 2 '07 #4

Chung Leong;62646 Wrote:
>
getdate(time() - (2*3600)) perhaps?
Yes that would work for the current time.

But as mentioned in my OP that will not work for 1/1/1970
you cannot do
>$date = getdate( 0 - (2*3600) );
as negative numbers are not accepted, (on the window server).
Regards.

FFMG
--

'webmaster forum' (http://www.httppoint.com) | 'webmaster Directory'
(http://www.webhostshunter.com/) | 'Recreation Vehicle insurance'
(http://www.insurance-owl.com/other/car_rec.php)
'Free URL redirection service' (http://urlkick.com/)
------------------------------------------------------------------------
FFMG's Profile: http://www.httppoint.com/member.php?userid=580
View this thread: http://www.httppoint.com/showthread.php?t=14320

Message Posted via the webmaster forum http://www.httppoint.com, (Ad revenue sharing).

May 2 '07 #5

ZeldorBlat;62659 Wrote:
On May 2, 3:03 am, FFMG <FFMG.2py...@no-mx.httppoint.comwrote:
Hi,

My timezone is GMT +2
So when I do a
$date = getdate( 0 );

I get:

$date =
{
['seconds'] (integer) = 0
['minutes'] (integer) = 0
['hours'] (integer) = 2 //<-- Hour is not 0 but +2
['mday'] (integer) = 1
['wday'] (integer) = 4
['mon'] (integer) = 1
['year'] (integer) = 1970
['yday'] (integer) = 0
['weekday'] (string) = "Thursday"
['month'] (string) = "January"
['0'] (integer) = 0

}

I cannot do:
$date = getdate( 0 - (2*3600) );
as negative numbers are not accepted, (on the window server).

So how can I do getdate( 0 ) and return the value without it been
converted by the server TZ.
Using setlocal(...) is also a bit of a Hacky kind of way of doing
things.

FFMG

--

'webmaster forum' (http://www.httppoint.com) | 'webmaster Directory'
(http://www.webhostshunter.com/) | 'Recreation Vehicle insurance'
(http://www.insurance-owl.com/other/car_rec.php)
'Free URL redirection service' (http://urlkick.com/)
------------------------------------------------------------------------
FFMG's Profile:http://www.httppoint.com/member.php?userid=580
View this thread:http://www.httppoint.com/showthread.php?t=14320

Message Posted via the webmaster forumhttp://www.httppoint.com, (Ad
revenue sharing).

Timestamps don't have a time zone -- they're always in GMT. So, when
you say a timestamp of zero, that's Jan 1, 1970 0:00 GMT -- which,
because your GMT offset is +2, is really Jan 1, 1970 02:00 in your
timezone.

What is it that you're trying to accomplish? Do you want the
timestamp for midnight on Jan 1, 1970 in /your/ timezone? Try this:

strtotime('Jan 1 2007');
My server is in the US with GMT+5 and I am working in GMT-2.
One is a *nix machine, the other a Windows.

I use a value of 0, (1/1/1970), to show that the date has not been
set.
The Unix Value is saved on the DB.
So when I do if( $date == 0) then ... I know that the date has not been
set.

mktime(...) as a GMT function but
getdate(...) does not.

And in my case I often use the two to set date ranges, (so if a user
registered on 1/1/1987 @ 12:33:20 I want to set the date on the DB as
1/1/1987 @ 00:00:00).

But because getdate(...) converts the dates sometimes it does not work
as expected.
For 1/1/1970 The date becomes 1/1/1969 19:00, (it works on the Unix
Box).
If the user registers between 0:00 and 05:00 they get access for the
day, (and sometimes the month before), because they pay by the day, I
don't want to cheat them.

So what I want is when I use getdate(0) I will get just that, the
1/1/1970 0:00:00, without having to worry about TZ.

At the end of the day I want to be assured that the date I passed to
getdate(...) is exactly the value that I passed, not a 'adjusted'
server time.

I hope I am making it a little clearer what I am using the dates for.

FFMG
--

'webmaster forum' (http://www.httppoint.com) | 'webmaster Directory'
(http://www.webhostshunter.com/) | 'Recreation Vehicle insurance'
(http://www.insurance-owl.com/other/car_rec.php)
'Free URL redirection service' (http://urlkick.com/)
------------------------------------------------------------------------
FFMG's Profile: http://www.httppoint.com/member.php?userid=580
View this thread: http://www.httppoint.com/showthread.php?t=14320

Message Posted via the webmaster forum http://www.httppoint.com, (Ad revenue sharing).

May 2 '07 #6
On May 2, 6:36 pm, FFMG <FFMG.2py...@no-mx.httppoint.comwrote:
Chung Leong;62646 Wrote:
getdate(time() - (2*3600)) perhaps?

Yes that would work for the current time.

But as mentioned in my OP that will not work for 1/1/1970
you cannot do
$date = getdate( 0 - (2*3600) );
as negative numbers are not accepted, (on the window server).

Regards.

FFMG

--

'webmaster forum' (http://www.httppoint.com) | 'webmaster Directory'
(http://www.webhostshunter.com/) | 'Recreation Vehicle insurance'
(http://www.insurance-owl.com/other/car_rec.php)
'Free URL redirection service' (http://urlkick.com/)
------------------------------------------------------------------------
FFMG's Profile:http://www.httppoint.com/member.php?userid=580
View this thread:http://www.httppoint.com/showthread.php?t=14320

Message Posted via the webmaster forumhttp://www.httppoint.com, (Ad revenue sharing).
Sorry. Wasn't reading carefully.

As there is no GMT version of getdate(), I think you'll need to obtain
each component of the date using gmdate().

May 2 '07 #7

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

Similar topics

4
by: Simon Gare | last post by:
Hi all, I am trying to retrieve a count of booking entries made 30 days ago, below is the end of the query I am having problems with. dbo.booking_form.TimeOfBooking = DATEADD(day, -30,...
2
by: Ben | last post by:
Hi at all, I read this contribute on www.php.net about backup of mysql databases and/or tables using PHP system function with this script I tryed to write a custom script to save only one...
2
by: matthewanxa | last post by:
Please forgive me, I am a neophyte at this :) I need to select all records created today I can't use GetDate because it looks for a specific hour minute and second so I need a range. ie...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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: 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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.