Solved

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

Posted on 2008-10-14
2
211 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
MarkMyburgh earned 500 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

739 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