datetime - Basic PHP timezones conversion -


i have looked @ previous questions , nothing seems fit require.

i working on scheduling system , client wants add timezones.

so need able proform action @ specific date , time.

lets chooses have alert @ following date/time:

25-12-2010 13:01:00 + / - timezone

i need able store in mysql unix_timestamp, have been looking @ php's datetime , datetimezone has confused me more.

i have looked @ strtotime also, unsure of best way work out date/time offset.

just make sure we're on same page, want reiterate unix timestamp merely number of seconds since "unix epoch" (january 1, 1970). therefore simple math work on unix timestamps.

there 2 ways go this; judging post you're confused you'd use.

the first way easiest (and logical) way, , store offset (if have it, is) , multiply 3600 (1 hour in seconds), , add that value current unix timestamp final time of running.

another way use datetime , datetimezone classes. how these 2 classes work, shown here, create 2 datetimezone objects, 1 timezone , 1 theirs; create 2 datetime objects first parameters being "now" , second being reference datetimezone objects above (respectively); , call getoffset method on your timezone object passing their timezone object first parameter, getting offset in seconds can added current unix timestamp time their job needs run.

the second way seems more complex such easy task if myself, first solution may suit needs better. however, if wish have more complete method, using datetime , datetimezone possibility.

quick note on strtotime: strtotime easy opposite of date() command, , won't of more use "tool" achieve looking for. in , of not convert or find offsets you; converts formatted date , time unix timestamp.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -