开发者

Change iphone time

开发者 https://www.devze.com 2023-01-09 18:05 出处:网络
I want to set the time of system in the iphone application,but i don\'t know how to d开发者_运维技巧o.

I want to set the time of system in the iphone application,but i don't know how to d开发者_运维技巧o. Would you know? Please tell me,thank you!


You can't, as there is no public API provided by Apple to do that. Even then, it's bad practice to try and change a user system setting like that.


Alternative: Use an NSDate and then modify it accordingly.

NSDate* now = [NSDate date];
    int hour = [[now dateWithCalendarFormat:nil timeZone:nil] hourOfDay];
    int min = [[now dateWithCalendarFormat:nil timeZone:nil] minuteOfHour];
    int sec = [[now dateWithCalendarFormat:nil timeZone:nil] secondOfMinute];
    NSLog(@"%d  /  %d  /  %d", hour+offset1, min+offset2, sec+offset2);

But you truly can't change the system clock. But, maybe this will help with what you want to do.


It is not possible, check out this forum link:

http://www.iphonedevsdk.com/forum/iphone-sdk-development/51285-can-we-change-device-time-using-application.html

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号