1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

I need DD-MM-YYYY HH:MM:SS AM/PM Format

Discussion in 'C#' started by Ridder, Dec 2, 2008.

  1. #1

    Iam using ASP,
    SEMrush
    I need DD-MM-YYYY HH:MM:SS AM/PM Format instead of mm/dd/yyyy hh:mm:ss am/pm .

    Can any one help me solve this issue, Thanks in advance.

     
    Ridder, Dec 2, 2008 IP
    SEMrush
  2. yugolancer

    yugolancer Well-Known Member

    Messages:
    321
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    110
    #2
    You can use any culture that supports the dd-mm-yyyy format like the french one.

    For example to format the date time now in a format dd-mm-yyyy you can do as follows:

    cultureInfo culture = new cultureinfo("fr-FR");
    string oFormatedDate = dtNow.ToString("d", culture);

    www.vbisbetter.com
     
    yugolancer, Dec 3, 2008 IP
  3. sukkepan

    sukkepan Guest

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Either that, or you can specify the date/time format directly as the parameter of the ToString method:

    string dateTime = DateTime.Now.ToString("dd-MM-yyyy hh:mm:ss");

    EDIT:

    I just noticed you want to show AM/PM as well, you can show that if you add "tt" in your format string:

    string dateTime = DateTime.Now.ToString("dd-MM-yyyy hh:mm:ss tt");
     
    sukkepan, Dec 4, 2008 IP
  4. yugolancer

    yugolancer Well-Known Member

    Messages:
    321
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    110
    #4
    Just out of curiosity; for which part of the world you want to set up the time?
     
    yugolancer, Dec 5, 2008 IP