Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 08-29-2009, 11:05 PM   #1 (permalink)
shad1236
Registered Member
 
Join Date: Aug 2009
Location: US
Posts: 31
shad1236 is on a distinguished road
Lightbulb NSString to NSDate

I got a string that contains the current date by using this :

Code:
NSString *date = [[NSDate date] description];
At a different point I am want to retrieve the date from this string and I use the following code
Code:
[NSDateFormatter setDefaultFormatterBehavior:NSDateFormatterBehavior10_4];
	NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
	//[NSDateFormatter setDefaultFormatterBehavior:NSDateFormatterBehaviorDefault];
	[dateFormatter setDateFormat:@"YYYY-MM-DD HH:MM:SS ±HHMM"];

	NSDate *dateFromString = [[NSDate alloc] init];
	dateFromString = [dateFormatter dateFromString:<NSString containing date>];
I am getting 'dateFromString' as nil 0x0. What I am doing wrong?
shad1236 is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 175,178
Threads: 93,918
Posts: 402,141
Top Poster: BrianSlick (7,966)
Welcome to our newest member, HugoMSousa
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 12:21 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.