タスクの期日を今日の 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
ますか?