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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:52:03+00:00 2026-06-18T07:52:03+00:00

The Unicode Date Format Patterns guide ( here ) state that appending an ‘a’

  • 0

The Unicode Date Format Patterns guide (here) state that appending an ‘a’ to the format will get the period (AM or PM for instance), e.g.,

[formatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss a"];

However I wish to ensure that the period information does not appear but I cannot find a format string to do that. The format string I am using is as follows:

[formatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss"];

unfortunately, when I use stringFromDate I get the following:

2013-01-09T11:11:00 AM

I dont wish to simply strip AM or PM from the resultant string because the period syntax may be different in differing Calendars etc, I just want to stop the period information appearing.

—-8<——

Consider the following code

NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setLocale:[NSLocale currentLocale]];
[formatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];
[formatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss"];
NSString *stringDate = [formatter stringFromDate:[NSDate date]];

self.labelOutput.text = stringDate;

[formatter release];

This code will produce a string in the format I want – however I cannot use it for memory management reasons. The app I am working on is plagued by NSDateFormatter memory leaks. So we use a singleton class to provide a set number NSDateFormatters to the app which are never released and therefore we minimise how much memory is being leaked. Unfortunately these static NSDateFormatters are appending AM / PM even when I apply a date format string thus:

NSDateFormatter *formatter = [MyDateFormatter dateFormat:kFormatDateMediumStyleTimeShortStyle];

[formatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];
[formatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss"];
  • 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-18T07:52:04+00:00Added an answer on June 18, 2026 at 7:52 am

    Here is the answer I have settled on. It’s a bit simplistic but it does the job.

    @interface NSDateFormatter (Utils)
    
    - (NSString *)stringWithNoPeriodInformationFromDate:(NSDate*)date;
    
    @end
    
    @implementation NSDateFormatter (Utils)
    
    - (NSString *)stringWithNoPeriodInformationFromDate:(NSDate*)date
    {
        NSString *stringWithPotentialPeriodInformation = [self stringFromDate:date];
        NSString *stringWithNoAMInformation = [stringWithPotentialPeriodInformation stringByReplacingOccurrencesOfString:[self AMSymbol] withString:@""];
        NSString *stringWithNoPeriodInformation = [stringWithNoAMInformation stringByReplacingOccurrencesOfString:[self PMSymbol] withString:@""];
    
        return stringWithNoPeriodInformation;
    }
    
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to decode Unicode strings to UTF-8 when inserting in a table. Here's
I want to make an application that will allow people to form groups to
I am trying to write a view/SQLAlchemy query that will allow me to display
From the grappelli customization document, it suggested that: The sortable-field will not automatically be
I use python-twitter to get the date of a tweet and try to parse
I am trying to set the date format for something like 2011-04-21 03:31:37.310396. I
Here's some code in a django tutorial that I'm going through. I've never come
Sometimes self.start is unicode: eg. >>>self.start u'07:30:00' Which makes datetime.combine complain start = datetime.combine(self.job_record.date,
Unicode has a million icon-like glyphs, but they're not always easy to search by,
Some Unicode data is stored in file as '\u84b8\u6c7d\u5730' without any encoding. Is there

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.