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 7567241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:36:58+00:00 2026-05-30T14:36:58+00:00

im using a string to convert it to an nsDate is working fine, but

  • 0

im using a string to convert it to an nsDate

is working fine,
but when i try to add time to my string I get null on the logs

NSString *dateStringus = [NSString stringWithFormat:@"12-09-2011"];
NSLog(@"%@",dateStringus);

NSDateFormatter *dateFormattero = [[NSDateFormatter alloc] init];

[dateFormattero setDateFormat:@"dd-MM-yyyy"];

NSDate* d = [dateFormattero dateFromString:dateStringus];
NSLog(@"tomad tu string date ::%@",d);    

NSString *pingus = [dateFormattero stringFromDate:d];

NSLog(@"transumatada ::%@", pingus);

NSLog(@"\n");

Works fine for only date,
but

if I do

NSString *dateStringus = [NSString stringWithFormat:@"12-09-2011 14:14:00"];

I get null on the logs

how to fix this string to include time? thanks!

  • 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-05-30T14:37:00+00:00Added an answer on May 30, 2026 at 2:37 pm

    The dateFormat property of the NSDateFormatter dateFormattero must match the format of date/time in the string dateStringus.

    Change:

    [dateFormattero setDateFormat:@"dd-MM-yyyy"];
    

    Into:

    [dateFormattero setDateFormat:@"dd-MM-yyyy HH:mm:ss"];
    

    Here is a good reference on date format patterns.

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

Sidebar

Related Questions

I am trying to convert string into NSDate using following code. NSString *old =
I'm using this code to convert a string to a date : +(NSDate*)dateTexteFromString:(NSString*)someString {
How do I convert string(09-Apr-2010) in to date time (09 April 2010 00:00:00) using
We try to convert from string to Byte[] using the following Java code: String
I need to convert a NSDate to a string using my personal data format...
I am using following code to convert string to sha1 string but i am
How to convert that string: 2011-08-24T14:06:10Z to NSDate using NSDateFormatter. I don´t know which
How do I convert string 2010-11-19T20:00:00Z into an NSDate object? I've tried using [dateFormatter
How can I convert TO a Nullable from a String using reflection? I have
I'm trying to convert the String \something\ into the String \\something\\ using replaceAll ,

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.