0

My friend is echoing the date using date(G:i:s) but the result getting displayed is neither the current system time nor the xampp server time (as he is using xampp).

so what is the possible reason for this problem and the solution to this problem.

Thanks in advance

1
  • How far out is the returned results? Is it out by a whole number of hours? If so, there is a timezone issue on the server. Commented Aug 12, 2010 at 3:26

2 Answers 2

1

According to http://www.php.net/manual/en/function.date-default-timezone-get.php, the function

date_default_timezone_get()

will return the currently configured timezone of the running script. If no timezone was set via either a runtime option or PHP INI file, it will return the UTC timezone. This will let you figure out what is going on.

To set the timezone to what you want, use

date_default_timezone_set()

Link: http://www.php.net/manual/en/function.date-default-timezone-set.php

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

Comments

0

date('G:i:s') ?

2 Comments

I thought so too, but php should spit out a parse error, not an arbitrary date.
PHP assumes unrecognised tokens are strings in many cases. It's a legacy "feature" :)

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.