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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:50:23+00:00 2026-05-17T15:50:23+00:00

I’m attempting to format dates for a French customer. I need to format Times

  • 0

I’m attempting to format dates for a French customer.

I need to format Times as shown in the following examples…

06:00 -> 6 h
08:45 -> 8 h 45
10:30 -> 10 h 30
15:00 -> 15 h
17:22 -> 17 h 22
18:00 -> 18 h

I’ve been able to use Custom Date and Time Formatting. But I seem to be stuck on this notation that the French (Canadian at least) don’t show the Minutes if they are zero “00”.

Currently I’m using the following format.

myDateTime.ToString("H \h mm")

How can I make it so “mm” only appears when > 00?

I’d like to avoid the use of an extension method or proxy class since I feel this should be built into the framework. Apparently its standard formatting for French times.

My string “H \h mm” is actually coming from a resource file. ie…

myDateTime.ToString(Resources.Strings.CustomTimeFormat);
  • 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-17T15:50:24+00:00Added an answer on May 17, 2026 at 3:50 pm

    I have some bad news for you. The framework does not support the format you are looking for. The following code proves this:

    using System;
    using System.Globalization;
    
    namespace ConsoleApplication1
    {
        public class Program
        {
            static void Main(string[] args)
            {
                // FR Canadian
                Console.WriteLine("Displaying for: fr-CA");
                DisplayDatesForCulture("fr-CA");
    
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine();
    
                // FR French
                Console.WriteLine("Displaying for: fr-FR");
                DisplayDatesForCulture("fr-FR"); 
    
                Console.WriteLine();
                Console.WriteLine("Press enter to exit.");
                Console.ReadLine();
            }
    
            static void DisplayDatesForCulture(string culture)
            {
                var ci = CultureInfo.GetCultureInfo(culture);
                var dt = new DateTime(2010, 10, 8, 18, 0, 0);
    
                foreach (string s in ci.DateTimeFormat.GetAllDateTimePatterns())
                    Console.WriteLine(dt.ToString(s));
            }
        }
    }
    

    The app displays all supported datetime formats. None of them support the concept of 18:00 ==> 18 h, etc.

    Your best option is to write an extension method or similar approach.

    Culture sensitive approach: build an extension helper class:

    public static class DateHelper
    {
        public static string ToLocalizedLongTimeString(this DateTime target)
        {
            return ToLocalizedLongTimeString(target, CultureInfo.CurrentCulture);
        }
    
        public static string ToLocalizedLongTimeString(this DateTime target, 
            CultureInfo ci)
        {
            // I'm only looking for fr-CA because the OP mentioned this 
            // is specific to fr-CA situations...
            if (ci.Name == "fr-CA")
            {
                if (target.Minute == 0)
                {
                    return target.ToString("H' h'");
                }
                else
                {
                    return target.ToString("H' h 'mm");
                }
            }
            else
            {
                return target.ToLongTimeString();
            }
        }
    }
    

    You can test like so:

    var dt = new DateTime(2010, 10, 8, 18, 0, 0);
    
    // this line will return 18 h
    Console.WriteLine(dt.ToLocalizedLongTimeString(CultureInfo.GetCultureInfo("fr-CA")));
    
    // this line returns 6:00:00 PM
    Console.WriteLine(dt.ToLocalizedLongTimeString());
    
    var dt2 = new DateTime(2010, 10, 8, 18, 45, 0);
    
    // this line will return 18 h 45
    Console.WriteLine(dt2.ToLocalizedLongTimeString(CultureInfo.GetCultureInfo("fr-CA")));
    
    // this line returns 6:45:00 PM
    Console.WriteLine(dt2.ToLocalizedLongTimeString());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

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.