Dinesh Santhalingam

Dinesh Santhalingam

  • NA
  • 737
  • 358.9k

Time change format in C#

Sep 1 2017 12:58 AM
I want to get the current datetime in MM/dd/YYYY hh:mm:ss tt format .The system time may in whatever the format.
 
Using Datetime.Now the time format may found.
  1. String timeformat= DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss tt");  
o/p is : 01/9/2017 10:00:05 AM
 
But I want to convert this string to datetime variable with change in format.
  1. DateTime timeformat1= Convert.ToDateTime(timeformat);  
My o/p will like be :   9/01/2017 10:00:05 AM  
 
Please help me to solve this.
 
or else I want to get the Datetime in MM/dd/YYYY HH:mm:ss tt format. 
 
Help me to solve this. 

Answers (7)