Friday, 4 April 2014

NSDateFormatter. NSString from NSDate. Convert date to string in iOS.

+(NSString*)convertDateToString:(NSDate *)date;
{  
    NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
    [dateFormat setDateFormat:@"yyyy-MM-dd"];

    NSDateFormatter *timeFormat = [[NSDateFormatter alloc] init];
    [timeFormat setDateFormat:@"HH:mm:ss"];


    NSString *theDate = [dateFormat stringFromDate:date];
    NSString *theTime = [timeFormat stringFromDate:date];
    return theDate;



}

No comments:

Post a Comment