soundari
soundari

Reputation: 35

How to get correct date not by system date in php

How to get correct date not by system date in php

For ex: actual date is 24/4/2013, but I changed my system date is 25/4/2013.

How can get correct date ie 24/4/2013?

Upvotes: 1

Views: 428

Answers (3)

user2304118
user2304118

Reputation:

Set the default time zone prior to use the date() function.

For instance:

date_default_timezone_set('UTC');
// or 
// date_default_timezone_set('Europe/Madrid')

echo date("Y-m-d H:i:s");

Upvotes: 0

Brandon
Brandon

Reputation: 284

PHP can't inherently know that your system time is incorrect. As others have pointed out, you can query an authoritative source (similar to the solution offered here) instead.

EDIT: shortcut to the time server query example

Upvotes: 2

7stud
7stud

Reputation: 48599

http://tf.nist.gov/tf-cgi/servers.cgi

,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

Upvotes: 2

Related Questions