0

I have a NSString filled with the following from my json parser.

"2013-08-22 00:00:00";

How i can i remove the timestamp from this? "00:00:00";

Thanks.

P.s i tried using the substringWithRange:NSMakeRange function.

David Rönnqvist
  • 56,267
  • 18
  • 167
  • 205
Cliffordwh
  • 1,422
  • 1
  • 10
  • 18

1 Answers1

3

If the date format in the string will remain same, then you can split the string based on the space in between.

Code to do that is:

NSString *date = @"2013-08-22 00:00:00";
NSArray *split = [date componentsSeparatedByString:@" "];
//split[0] => Date part
//split[1] => Time part

This is a quick fix.

Hope that helps!

Amar
  • 13,202
  • 7
  • 53
  • 71