Converting time string to Date format iOS

戏子无情 提交于 2019-12-10 19:55:34

问题


I have a string @"21:57" and I want to save it with the same HH:mm format in NSDate. I tried converting it using:

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
dateFormatter.dateFormat = @"HH:mm";
NSDate *date  = [dateFormatter dateFromString:stringToConvertFrom];

but I'm getting 2000-01-01 21:57:00 +0000 instead of 21:57.

来源:https://stackoverflow.com/questions/18724190/converting-time-string-to-date-format-ios

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!