我将任务的截止日期保存为今天 8:45。但是日志显示截止日期为
2013-04-26 01:45:46 +0000
是什么赋予了?这是我的代码
#import "DatePickerViewController.h"
#import <Parse/Parse.h>
#import "ListItemObject.h"
@class ListItemObject;
@interface DatePickerViewController ()
@end
@implementation DatePickerViewController
@synthesize dateLabel;
@synthesize pick;
@synthesize listFieldText;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
pick.timeZone = [NSTimeZone localTimeZone];
UIBarButtonItem *saveDate = [[UIBarButtonItem alloc]
initWithTitle:@"Save Date"
style:UIBarButtonItemStyleDone
target:self
action:@selector(saveList:)];
self.navigationItem.rightBarButtonItem = saveDate;
[pick addTarget:self action:@selector(updateDateLabel:) forControlEvents:UIControlEventValueChanged];
}
-(IBAction)saveList:(id)sender {
NSLog(@"%@", pick.date);
[ListItemObject saveListItem:[PFUser currentUser] withName:listFieldText withDate:pick.date];
[self.navigationController popViewControllerAnimated:YES];
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
}
-(IBAction)updateDateLabel:(id)sender {
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateStyle:NSDateFormatterLongStyle];
[formatter setTimeStyle:NSDateFormatterMediumStyle];
dateLabel.text = [formatter stringFromDate:pick.date];
}
我是否需要做与我所做的类似的事情NSDateFormatter
?