Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9233875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:39:20+00:00 2026-06-18T06:39:20+00:00

I think I am using the NSDateFormatter in a wrong way. I have a

  • 0

I think I am using the NSDateFormatter in a wrong way. I have a UIDatePicker. When I select a date, my day label ,month label, year label and time label is set.

When I click on a save button I build up a date with this labels and send it to my server.
I do it like this.

 NSString *dateStringBegin = [NSString stringWithFormat:@"%@ %@ %@ %@",lblBeginDay.text,lblBeginMonth.text,lblBeginYear.text,lblBeginTime.text];

//LOG dateStringBegin =  7 februari 2013 11:21

But my server only accepts a string that looks like this 2013-02-07 11:21

Now I am doing this in code.

 NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
    [dateFormat setDateFormat:@"d MMMM YYYY hh:mm"];
    NSDate* date = [dateFormat dateFromString:dateStringBegin];

    NSDateFormatter *dateFormat2 = [[NSDateFormatter alloc] init];
    [dateFormat2 setDateFormat:@"YYYY-MM-dd HH:mm"];
    NSString *dateStringBegin2 =  [dateFormat2 stringFromDate:date];

Now when I look at how my dateStringBegin2 looks like, I see this.

//LOG dateStringBegin2 = 2013-12-28 11:21
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T06:39:21+00:00Added an answer on June 18, 2026 at 6:39 am

    Check this code:-

    NSString *dateStringBegin = @"7 february 2013 11:21";
        NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
        [dateFormat setDateFormat:@"dd MMMM yyyy hh:mm"];
        NSDate* date = [dateFormat dateFromString:dateStringBegin];
    
        NSDateFormatter *dateFormat2 = [[NSDateFormatter alloc] init];
        [dateFormat2 setDateFormat:@"yyyy-MM-dd HH:mm"];
        NSString *dateStringBegin2 =  [dateFormat2 stringFromDate:date];
        NSLog(@"Date : %@",dateStringBegin2);
    

    Hope it helps you..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think I'm using Django in google app engine this way: from google.appengine.ext.webapp import
I have a situation where I think using the 'em' metric would be perfect.
Its generally related to a question in magento ..but i think using core php
I don't think that using .ini or .xml file is a good idea with
To make my extranet web application even faster/more scalable I think of using some
I think I'm using the Users API incorrectly: class BaseHandler(webapp.RequestHandler): user = users.get_current_user() def
i'm having a little issue with doctrine using symfony 1.4 (I think it's using
New to MVVM so please excuse my ignorance. I THINK i'm using it right
I think that this problem can be sorted using reflection (a technology which I'm
I am using Telerik's RadDatePicker control which i think is essentially a DateTime control

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.