php - The proper way to set the time zone in the area you are accessing the script from -
i hope inquire question properly. script below setting time notify user many minutes or hours before appointment date-time. programme stored on server in chicago time zone user in new york time zone or los angeles. want time set there appointments right at. way setting timezone proper way it. user setting there time zone in there profile , in script below added in $stm['timez']. peace of script part of larger script run in cron send out reminders
$newsub = $stm['rtime']; // time needs subtracted scheduled date comes remindertime table $datetrue =$stm['signstart'] . ' ' . $stm['starttime']; //the schedule appointment time $datetime = new datetime($datetrue, new datetimezone($stm['timez'])); //datetimezone timezone profile working in america/los_angeles or america/new york $senddate1 = $datetime->format("y-m-d h:i"); //the date in selected timezone $date = date_create($senddate1); $date1 = date_sub($date, date_interval_create_from_date_string($newsub)); //subtract amount of time before appointment time want reminder sent $senddate = date_format($date1,'y-m-d h:i');//the datetime send reminder
do date_default_timezone_set ()
.
put @ top of script , time related functions asssume you're using defined time zone.
check out the manual, , list of supported timezones.
edit
if don't know user's timezone off hand can either guess @ javascript...
var offset = new date().gettimezoneoffset();
or use client ip address, geocode , guess @ location way.
php timezone
No comments:
Post a Comment