Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. DateTime format

DateTime format

Scheduled Pinned Locked Moved ASP.NET
csharpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rachitdamani
    wrote on last edited by
    #1

    Hi All, I need to display time in the following format in c#: 7:40a (not AM/PM whole word just A/P in lowercase) So how could I achieve this?

    N 1 Reply Last reply
    0
    • R rachitdamani

      Hi All, I need to display time in the following format in c#: 7:40a (not AM/PM whole word just A/P in lowercase) So how could I achieve this?

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      rachitdamani wrote:

      I need to display time in the following format in c#: 7:40a

      I don't know this is the rite method. But it will work Try

      string strDate = DateTime.Now.ToShortTimeString();
      strDate = strDate.ToLower().Replace("am","a");
      strDate = strDate.ToLower().Replace("pm","p");
      Console.WriteLine(strDate);
      Console.ReadLine();

      :cool:


      printf("Navaneeth!!") www.w3hearts.com

      R 1 Reply Last reply
      0
      • N N a v a n e e t h

        rachitdamani wrote:

        I need to display time in the following format in c#: 7:40a

        I don't know this is the rite method. But it will work Try

        string strDate = DateTime.Now.ToShortTimeString();
        strDate = strDate.ToLower().Replace("am","a");
        strDate = strDate.ToLower().Replace("pm","p");
        Console.WriteLine(strDate);
        Console.ReadLine();

        :cool:


        printf("Navaneeth!!") www.w3hearts.com

        R Offline
        R Offline
        rachitdamani
        wrote on last edited by
        #3

        Thnx buddy, it is working fine.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups