Reputation: 3349
I am developing a iPhone app which need to store time data with client time zone in a remote mysql database. This is doing by calling a php web service and store data in mysql database. What is the best way to find user timezone and send to web service.
edit:
NSTimeZone *tzone = [NSTimeZone defaultTimeZone];
NSTimeInterval timeInt = [dateTime timeIntervalSince1970 ];
NSNumber *timeStamp=[NSNumber numberWithInt:timeInt];
NSString *zone = [tzone name];
NSURL *url = [NSURL URLWithString:@"http://localhost/mytask/"];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setPostValue:[NSString stringWithFormat:@"%@", timeStamp] forKey:@"task_time_stamp"];
[request setPostValue:zone forKey:@"task_time_zone"];
How to save time stamp in MySql database with client timezone. is there any other approach.
Upvotes: 1
Views: 444
Reputation: 14253
SET time_zone = 'America/New_York';
this can change the time zone setting of mysql db .execute before insert . if u want to know the current time-zone in php u can use date_default_timezone_get
.
Upvotes: 1