gpt4 book ai didi

iphone - 保存事件执行的当前时间

转载 作者:行者123 更新时间:2023-12-03 21:02:56 25 4
gpt4 key购买 nike

在我的应用程序中,我使用 zbar sdk 来扫描票证,我想在相机拍照时在 sqlite 中保存当前时间。我怎样才能做到这一点。提前致谢。

最佳答案

以下代码用于获取设备本地当前时间。

 NSDate* sourceDate = [NSDate date];

NSTimeZone* sourceTimeZone = [NSTimeZone timeZoneWithAbbreviation:@"GMT"];
NSTimeZone* destinationTimeZone = [NSTimeZone systemTimeZone];

NSInteger sourceGMTOffset = [sourceTimeZone secondsFromGMTForDate:sourceDate];
NSInteger destinationGMTOffset = [destinationTimeZone secondsFromGMTForDate:sourceDate];
NSTimeInterval interval = destinationGMTOffset - sourceGMTOffset;

NSDate* destinationDate = [[[NSDate alloc] initWithTimeInterval:interval sinceDate:sourceDate] autorelease];

希望这对编码有很大帮助

关于iphone - 保存事件执行的当前时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12720608/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com