Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

problem with date function

Question posted by: Jorge Reyes (Guest) on March 18th, 2008 07:15 PM
Hi everyone i have this problem, when i use date('Y-m-d H:i:s') its
returning 1 more hour than it is, i mean if now is 2008-03-18
13:16:00:00 my function returns 2008-03-18 13:17:00:00, so the
question is why?. I check this on the php.ini and i don´t found
anything related and of course my server time is ok i check it, thanks
for your help.
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
=?iso-8859-1?Q?=C1lvaro?= G. Vicario's Avatar
=?iso-8859-1?Q?=C1lvaro?= G. Vicario
Guest
n/a Posts
March 18th, 2008
07:45 PM
#2

Re: problem with date function
*** Jorge Reyes escribió/wrote (Tue, 18 Mar 2008 12:14:54 -0700 (PDT)):
Quote:
Originally Posted by
Hi everyone i have this problem, when i use date('Y-m-d H:i:s') its
returning 1 more hour than it is, i mean if now is 2008-03-18
13:16:00:00 my function returns 2008-03-18 13:17:00:00, so the
question is why?. I check this on the php.ini and i don´t found
anything related and of course my server time is ok i check it, thanks
for your help.


What's your date.timezone directive like? Do you get any notice if you run
the command this way?:

<?php

ini_set('display_errors', 1);
error_reporting(E_ALL | E_STRICT);
echo date('Y-m-d H:i:s');

?>



--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor en cubitos: http://www.demogracia.com
--

Rik Wasmus's Avatar
Rik Wasmus
Guest
n/a Posts
March 18th, 2008
09:45 PM
#3

Re: problem with date function
On Tue, 18 Mar 2008 20:14:54 +0100, Jorge Reyes <jorg_reyes@hotmail.com>
wrote:
Quote:
Originally Posted by
Hi everyone i have this problem, when i use date('Y-m-d H:i:s') its
returning 1 more hour than it is, i mean if now is 2008-03-18
13:16:00:00 my function returns 2008-03-18 13:17:00:00, so the
question is why?. I check this on the php.ini and i don´t found
anything related and of course my server time is ok i check it, thanks
for your help.


Y -m -d H :i :s
2008-03-18 13:17:00:00

Where does the extra ':00' come from? Is this a typing error, or is your
clock just 1 minute off?
--
Rik Wasmus

Jorge Reyes's Avatar
Jorge Reyes
Guest
n/a Posts
March 18th, 2008
10:15 PM
#4

Re: problem with date function
On 18 mar, 13:44, "Álvaro G. Vicario"
<webmasterNOSPAMTHA...@demogracia.comwrote:
Quote:
Originally Posted by
*** Jorge Reyes escribió/wrote (Tue, 18 Mar 2008 12:14:54 -0700 (PDT)):
>
Quote:
Originally Posted by
Hi everyone i have this problem, when i use date('Y-m-d H:i:s') its
returning 1 more hour than it is, i mean if now is 2008-03-18
13:16:00:00 my function returns *2008-03-18 13:17:00:00, so the
question is why?. I check this on the php.ini and i don´t found
anything related and of course my server time is ok i check it, thanks
for your help.

>
What's your date.timezone directive like? Do you get any notice if you run
the command this way?:
>
<?php
>
ini_set('display_errors', 1);
error_reporting(E_ALL | E_STRICT);
echo date('Y-m-d H:i:s');
>
?>
>
--
--http://alvaro.es- Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web:http://bits.demogracia.com
-- Mi web de humor en cubitos:http://www.demogracia.com
--


the date.timezone directive is commented just as default is, now i put
your lines and nothing happens, its showing the same 1 more hour, i
had to change my sql query because i need the time so now i am using
the sysdate() of the oracle server but i still need to undertstand
what happening. Regards

Jorge Reyes's Avatar
Jorge Reyes
Guest
n/a Posts
March 18th, 2008
10:25 PM
#5

Re: problem with date function
On 18 mar, 15:43, "Rik Wasmus" <luiheidsgoe...@hotmail.comwrote:
Quote:
Originally Posted by
On Tue, 18 Mar 2008 20:14:54 +0100, Jorge Reyes <jorg_re...@hotmail.com*
wrote:
>
Quote:
Originally Posted by
Hi everyone i have this problem, when i use date('Y-m-d H:i:s') its
returning 1 more hour than it is, i mean if now is 2008-03-18
13:16:00:00 my function returns *2008-03-18 13:17:00:00, so the
question is why?. I check this on the php.ini and i don´t found
anything related and of course my server time is ok i check it, thanks
for your help.

>
Y * -m -d *H :i :s
2008-03-18 13:17:00:00
>
Where does the extra ':00' come from? Is this a typing error, or is your *
clock just 1 minute off?
--
Rik Wasmus


yes sorry this is a typing error. this is the thing 13:16:00 sorry!
any idea?

Toby A Inkster's Avatar
Toby A Inkster
Guest
n/a Posts
March 19th, 2008
11:05 AM
#6

Re: problem with date function
Jorge Reyes wrote:
Quote:
Originally Posted by
Hi everyone i have this problem, when i use date('Y-m-d H:i:s') its
returning 1 more hour than it is


Try: date('Y-m-d H:i:s O')

This will add the timezone to the date. Is the timezone what you'd expect?

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 1 day, 12:04.]

The Semantic Web
http://tobyinkster.co.uk/blog/2008/03/09/sw/

Captain Paralytic's Avatar
Captain Paralytic
Guest
n/a Posts
March 19th, 2008
11:15 AM
#7

Re: problem with date function
On 18 Mar, 19:14, Jorge Reyes <jorg_re...@hotmail.comwrote:
Quote:
Originally Posted by
Hi everyone i have this problem, when i use date('Y-m-d H:i:s') its
returning 1 more hour than it is, i mean if now is 2008-03-18
13:16:00:00 my function returns 2008-03-18 13:17:00:00, so the
question is why?. I check this on the php.ini and i don´t found
anything related and of course my server time is ok i check it, thanks
for your help.


As far as I can see it is 1 minute not 1 hour out?

=?iso-8859-1?Q?=C1lvaro?= G. Vicario's Avatar
=?iso-8859-1?Q?=C1lvaro?= G. Vicario
Guest
n/a Posts
March 20th, 2008
10:45 AM
#8

Re: problem with date function
*** Jorge Reyes escribió/wrote (Tue, 18 Mar 2008 15:14:11 -0700 (PDT)):
Quote:
Originally Posted by
the date.timezone directive is commented just as default is


Right... Then uncomment it and give it a proper value. Mine is
"Europe/Madrid", yours will be similar. Find the list of available time
zones here:

http://es2.php.net/manual/en/timezones.php



--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor en cubitos: http://www.demogracia.com
--

 
Not the answer you were looking for? Post your question . . .
183,968 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Latest Articles: Read & Comment
  • Didn't find the answer you were looking for?
    Post Your Question
  • Top Community Contributors