1

i have a php code like this:

   date_default_timezone_set('GMT');
    $date =date( "Y-m-d H:i:s");
    echo $date;

output is

2011-05-01 11:31:49

but when insert $date in Datetime column date is 2011-05-01 11:05:07

INSERT CODE:

    date_default_timezone_set("GMT");
    $date=date("Y-m-d H:m:s");
    $q="insert into TABLE values
    ('$date')";
mysql_query($q);

why?

10
  • 3
    What exactly do you insert into your database? And did you check the time settings of the mysql server? Commented May 1, 2011 at 11:47
  • check the time settings of the mysql server? how? Commented May 1, 2011 at 11:57
  • it return same time with windows time. mysql server is localhost Commented May 1, 2011 at 12:18
  • Are you physically in GMT? Also, please let us know what your query looks like. Commented May 1, 2011 at 12:23
  • 1
    That's still not your query, table is a reserved work so you've just written a fake query for us to see what you did. But if you have an error in your true code, we won't be able to see it ;) Commented May 1, 2011 at 12:30

1 Answer 1

2

Your first example uses $date=date("Y-m-d H:i:s"); which seems ok.

Your second example uses $date=date("Y-m-d H:m:s"); which seems strange, you're using the month(m) in the conversion for minutes.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.