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

  • Home
  • SEARCH
  • 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 8114871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:17:09+00:00 2026-06-06T03:17:09+00:00

I want to set date in this format MMM dd, yyyy HH:mm, I hede

  • 0

I want to set date in this format MMM dd, yyyy HH:mm, I hede done code for this but there is some thing wrong which I don’t know.

NSDate *date = [NSDate date];
[format setDateFormat:@"MMM dd, yyyy HH:mm"];
NSLog(@"My date with out format = %@",date);
date = [format dateFromString:[format stringFromDate:date]];
NSLog(@"My date is = %@",date);

OUTPUT

My date with out format = 2012-06-22 09:53:46 +0000
My date is = 2012-06-22 09:53:00 +0000

Please help me where I am doing wrong.

Thanks in advance.

  • 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-06T03:17:10+00:00Added an answer on June 6, 2026 at 3:17 am

    Firstoff, NSDate does not know any thing about the formatting of the date. Thats where NSDateFormatter comes in.

    date = [format dateFromString:[format stringFromDate:date]];
    

    What you are doing here is create a string for the given format, which will also result in removing the timezone. and than create a new date from that string. Since it no longer has the timezone it will result in a date with GMT as time zone.

    But this will still result in a NSDate which holds, seconds and has a default time zone set to GMT.

    There is no need to make a new date object, if you want to display a date just take the string which the stringFromDate: method returns. If you do it like this it will work:

    NSDate *date = [NSDate date];
    [format setDateFormat:@"MMM dd, yyyy HH:mm"];
    NSLog(@"My date with out format = %@",date);
    NSString *dateString = [format stringFromDate:date];
    NSLog(@"My date is = %@",dateString);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to create a regex for Date in this format dd.MM.yyyy . I want
I want set Listbox background to transparent but not working Is there any idea?
i have a string with a date in this format yyyyMMddHHmmss, so i want
I am looking for a way to set date format in either mm/dd/yyyy or
Currently, I am using <%= String.Format({0:MMM dd, yyyy}, DateTime.Now)%> to get today's date in
According to this documentation, http://jqueryui.com/demos/datepicker/#option-altFormat I can set a different date format for the
I want to set user date format yyyyMMdd using culture name. Which culture name
I have a DATE datatype mysql column in a table. I want to set
I want to display result set of Years between From date - To date
i want set class for repeater when doPostBack for those dataID i wan but

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.