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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:52:44+00:00 2026-05-13T07:52:44+00:00

I have a DateTime string in 24 HOURS format .. 2009-12-31T23:59:59 I want it

  • 0

I have a DateTime string in 24 HOURS format .. “2009-12-31T23:59:59”

I want it in this format .. “12/31/2009 23:59:59” that is: “MM/DD/YYYY HH:MM:SS”

When I tried to covert it to string I am getting “12/31/2009 11:59:59 PM” .. though I can write a code for string manipulation .. it doesn’t seem to be the efficient one .. Moreover the case become worst when I have dateTime value like “2009-1-1T1:19:15” .. here, as the string length is varying, I can’t even trace the value of Hours and months using substring() and convert.ToInt() ..

I am using visual studio 2005, It is throwing error saying “Cannot implicitly convert DateTime to String” when I write this statement:
..

result = Convert.ToString(dateValue);

I simplify my question:
Is there any method to convert “yyyy-mm-ddThh:mm:ss” format to “mm/dd/yyyy hh:mm:ss” .. And it must work in visual studio 2005 ..

  • 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-13T07:52:44+00:00Added an answer on May 13, 2026 at 7:52 am

    You need to use ParseExact to get it back to datetime:

    string FormatDateTime(string dateString) {
        DateTime dt = DateTime.ParseExact(dateString, "yyyy-MM-ddTHH:mm:ss", DateTimeFormatInfo.InvariantInfo, DateTimeStyles.None);
        return dt.ToString("MM/dd/yyyy HH:mm:ss");
    }
    

    That should give you the desired output you are looking for. By using InvariantInfo, it will make sure you system settings don’t replace the slashes with whatever you have currently defined in the system. I think I saw in the comments that you had a “.” being used as your date separator.

    http://msdn.microsoft.com/en-us/library/system.globalization.datetimeformatinfo.dateseparator.aspx
    http://msdn.microsoft.com/en-us/library/system.globalization.datetimeformatinfo.invariantinfo.aspx

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

Sidebar

Related Questions

I have datetime data in string format like this: Sat Mar 24 23:59:59 GMT
I have date in this format 1999-05-31T13:20:00.000-05:00 I want to add some hours or
I have a problem while converting a string whose value is dd.mm.yyyy to DateTime
I have the following wonderfully unreliable statement: string LastsuccessfuldownloadDateTime = 04.07.2009 19:21:36 DateTime myDate
I have this object: class a { public string Application; public DateTime From, To;
So i have this DateTime? and what i want to do is to obtain
I have the following code: string textTransDate = String.Format({0}-{1}-{2} {3}:{4}, DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour,
I need string from datetime to display time in 24 hours format. .. var
I have a string called TheUserTime that looks like this: string TheUserTime = 12.12.2011.16.22;
I have the following statement DateTime now = DateTime.Now; string test = string.Format({0}{1}{2}{3}, now.Day,

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.