Summary: Formatting a date using DateTime.ParseExact. // Utgangspunkt: 04/25/2009 10:00 AM
string countDownClock = "04/25/2009 10:00 AM";
string format = "MM/dd/yyyy hh:mm tt";
CultureInfo provider = CultureInfo.InvariantCulture;
DateTime countDownClockParsed = DateTime.ParseExact(countDownClock, format, provider);
// Resultat: 25.04.2009 10:00:00
Response.Write(countDownClockParsed);
Husk å Importere System.Globalization namespace i toppen av siden slik:
using System.Globalization;
|