Link to home
Start Free TrialLog in
Avatar of Kirti Karande
Kirti Karande

asked on

Is it possible to convert a date to epoch independent of the server time on which the php script is running?

php date() returns the server time
even if the timezone is changed through script  the date() function returns the time set
database being on another server have timestamps stored as per gmt
m trying to extract data between a particular interval on the basis of epoch timestamp
Avatar of Nathan Riley
Nathan Riley
Flag of United States of America image

// object oriented
$date = new DateTime('01/15/2010'); // format: MM/DD/YYYY
echo $date->format('U'); 

// or procedural
$date = date_create('01/15/2010'); 
echo date_format($date, 'U');

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Pavel Celba
Pavel Celba
Flag of Czechia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Kirti Karande
Kirti Karande

ASKER

Worked as required .  thanks a lot