Accurate date formate and compare date in iphone dev?

后端 未结 2 526
借酒劲吻你
借酒劲吻你 2021-01-24 08:29

I am new in iphone, i want to change string into accurate date-formate which i couldn\'t done this for last 2 hrs. I have string like(17:30 18 Oct) and want to convert this in a

相关标签:
2条回答
  • 2021-01-24 09:13

    Try this

        NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
        [dateFormat setDateFormat:@"hh:mma dd/MMM"];
        NSString *dateString = [dateFormat stringFromDate:today];
        NSLog(@"date: %@", dateString);
        [dateFormat release];
    
    0 讨论(0)
  • 2021-01-24 09:31

    NSString to NSDate conversion

        NSString *dateString = @"6:30 18 Oct";
        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
        [dateFormatter setDateFormat:@"hh:mm dd/MMM"];
        NSDate *dateFromString = [[NSDate alloc] init];
        dateFromString = [dateFormatter dateFromString:dateString];
        [dateFormatter release];
    
    0 讨论(0)
提交回复
热议问题