Month and Year to standard format conversion

53 views Asked by At

I have month number and year separately,I want to convert them in yyyy-mm-dd hh:mm:ss +0000 format how can I do it.

I am trying the following code but it is not giving desired result.

 NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
 NSDateComponents *components = [NSDate componentsWithYear:year month:month day:1];  
 NSDate *date =  [calendar dateFromComponents:components];

when I am passing month as 8(Aug) and year as 2015 it is returning 3963801-06-02 18:30:00 +0000 .

The parameters I am passing, are in NSInteger.

Can anyone help.

0

There are 0 answers