Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Time in C#?
Message
De
21/06/2013 17:36:12
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, États-Unis
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01576867
Message ID:
01576892
Vues:
35
This message has been marked as a message which has helped to the initial question of the thread.
J'aime (1)
>Thanks, do you know how to get AM/PM as a string? I could not find this as a property of datetime class
var myTime = "10:01 AM";
var myDate = DateTime.Parse(myTime);
var myHours = myDate.Hour;
var myMinute = myDate.Minute;
var myAmPm = myDate.ToString("tt");
Note: myDate.Hour uses 24hour format, so 2:00 PM will read 14. If you want 2 you'll need to do .ToString("hh").
Very fitting: http://xkcd.com/386/
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform