0

I am not a dotNet developer and was trying to read up some documentation on the following method:

signDate = Convert.ToDateTime("6/22/2011 8:35:21 PM");

What would be an equivalent function/method in objective C?

milof
  • 696
  • 9
  • 25
  • 3
    I think it is pretty clear that this code converts a string to a datetime type object, isn't it? – Felipe Sabino Jun 23 '11 at 01:52
  • looks like a duplicate of this question: http://stackoverflow.com/questions/902950/iphone-convert-date-string-to-a-relative-time-stamp – blueberryfields Jun 23 '11 at 01:53
  • @Felipe Yes that is pretty obvious. And a simple Google search shows that http://msdn.microsoft.com/en-us/library/system.datetime.aspx however being a non .net developer, I do not know what a DateTime struct is in .net – milof Jun 23 '11 at 01:56
  • 1
    actually, what you should have checked is the `Convert` class reference, as it is the class performing the conversion. It has a lot of examples on the date string formats and the resulting dates http://msdn.microsoft.com/en-us/library/xhz1w05e.aspx ;) – Felipe Sabino Jun 23 '11 at 02:01

2 Answers2

2

I believe you should check out the NSDateFormatter Documentation. In particular, I believe you want the method dateFromString:

In addition, or for a quick overview, check out the Date Formatters Guide.

PengOne
  • 48,188
  • 17
  • 130
  • 149
2

I am also not a .NET developer, but it looks like you're looking for dateWithNaturalLanguageString:

NSDate *signDate = [NSDate dateWithNaturalLanguageString:@"6/22/2011 8:35:21 PM"];

Josh Leitzel
  • 15,089
  • 13
  • 59
  • 76