problem in DATE-TIME (c#) formatting, Help me plz..,

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nirmalsingh
    New Member
    • Sep 2006
    • 218

    problem in DATE-TIME (c#) formatting, Help me plz..,

    hi, my code is
    -------------------
    string demo="01-01-2007 04:59:21 PM";
    DateTime dtDate=Convert. ToDateTime(demo );
    string strDate = dtDate.ToString ("yyyy-MM-dd hh:mm:ss AM/PM");
    -------------------

    i want to convert the date in above string (demo) , to 2007-01-01 04:59:21 PM

    am or pm is not accepted and also internal server error is displayed. what to do? help me with sample code plz.
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    This article may help:
    Date and Time

    Comment

    • nirmalsingh
      New Member
      • Sep 2006
      • 218

      #3
      thanx but its in html, i need the sample coding in c#, boss.

      Comment

      • kenobewan
        Recognized Expert Specialist
        • Dec 2006
        • 4871

        #4
        Oops... try this one:
        Formatting Date and Time Values In .NET

        Comment

        • nirmalsingh
          New Member
          • Sep 2006
          • 218

          #5
          ok with that but am or pm is not considered, by default it assigns am for pm also. what to do..?

          Comment

          Working...