?
Solved

.NET: How to check whether a time is AM or PM

Posted on 2008-10-14
2
Medium Priority
?
217 Views
Last Modified: 2013-12-17
Hi, I there any way I can check whether a time is AM or PM in C#? Or I have to do all the logic myself?
0
Comment
Question by:karakav
2 Comments
 
LVL 1

Accepted Solution

by:
MarkMyburgh earned 2000 total points
ID: 22709856
not sure, but i suppose a simple hack would be

DateTime x = new DateTime(2008, 1, 1, 14, 0, 0);
bool am = x.TimeOfDay.Hours >= 13 ? false : true;
 
0
 
LVL 4

Author Closing Comment

by:karakav
ID: 31505818
Thanks. That's exactly what I needed. But Correct it this way: bool = x.Value.TimeOfDay.Hours >13?false:true;
0

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month17 days, 11 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question