Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Time in C#?
Message
From
21/06/2013 17:36:12
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, United States
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01576867
Message ID:
01576892
Views:
36
This message has been marked as a message which has helped to the initial question of the thread.
Likes (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/
Previous
Reply
Map
View

Click here to load this message in the networking platform