Solved

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

Posted on 2008-10-14
2
212 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

More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

691 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