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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:02:02+00:00 2026-06-14T09:02:02+00:00

I am trying to localize A.M. & P.M. in datetime in C#. How reliable

  • 0

I am trying to localize A.M. & P.M. in datetime in C#.

How reliable is it to use values returned by C#’s ‘PMDesignator’ & ‘AMDesignator’ (as in the code below) ?

How can I handle both the below scenarios using the same code?

                                                                        //Line# Output
                                                                        //----- ------
void Main()                                                             //1
{                                                                       //2
    DateTime dt = DateTime.Now; // it is 5:56 PM now                    //3 it is 5:56 PM now   
                                                                        //4
    //Japanese                                                          //5
    var JapaneseCulture = new System.Globalization.CultureInfo("ja");   //6 
    Console.WriteLine(JapaneseCulture.DateTimeFormat.PMDesignator);     //7     午後
    Console.WriteLine(JapaneseCulture.DateTimeFormat.AMDesignator);     //8     午前
    Console.WriteLine(dt.ToString("t",JapaneseCulture));                //9     17:56
    Console.WriteLine(dt.ToString("hh:mm tt",JapaneseCulture));         //10    05:56 午後
                                                                        //11
    //German                                                            //12
    var GermanCulture = new System.Globalization.CultureInfo("de");     //13    
    Console.WriteLine(GermanCulture.DateTimeFormat.PMDesignator);       //14    (blank)
    Console.WriteLine(GermanCulture.DateTimeFormat.AMDesignator);       //15    (blank)
    Console.WriteLine(dt.ToString("t",GermanCulture));                  //16    17:56
    Console.WriteLine(dt.ToString("hh:mm tt",GermanCulture));           //17    05:56
}

Japanese –
PMDesignator, AMDesignator have values,
but are not shown in Line 9 when using “t”.
In this case the format specified in Line 10 (“hh:mm tt”) gives more correct output.

German –
PMDesignator, AMDesignator don’t have values,
so using “t” as in Line 16 gives the correct output,
while Line 17 which uses “hh:mm tt” gives incorrect output.

[EDIT: After reading comments:]
Does “t” give the “typically” used formats fairly reliably? (I have no prior experience in localization, so I do not have a good idea of how reliable the values are)

  • 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-14T09:02:04+00:00Added an answer on June 14, 2026 at 9:02 am

    The Standard Date and Time Format Strings in .NET will do the correct thing for the user’s culture. In your case just use:

    var culture = new CultureInfo("ja");
    var dt = DateTime.Now;
    Console.WriteLine(dt.ToString("t", culture)); // t => Short Time format.
    

    Only override the culture-specific format with customizations if really required by a specific business requirement.

    Microsoft throws a lot of money at their localization efforts to ensure that formatting, translations, etc. are correct for everyone.

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

Sidebar

Related Questions

I'm trying to use jquery-localize to make a bilingual (pt-en) Shopify store. Jquery-localize is
I'm trying to use the LocBaml way (this might be my mistake) to localize
I'm trying to use update_attributes on a record, but it fails and I can't
I'm trying to localize an asp.net web application. Consider the following asp.net code. I'm
I have been working on mvc3 application and trying to localize the same. I
I'm facing a strange issue, I'm trying to localize a website, so i converted
Trying to figure out how I can do this properly. The print_r looks like
Trying to localize text in ASP.NET labels... want to add a ':' after the
I'm trying to localize client side Javascript in a ASP .NET MVC application. The
I am trying to localize an existing cakephp application. For the most part I

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.