General Audience
1✕
Loading...
Bad Date Comparisons in C# - if (DateTime.Now.ToString() == "01/01/2022 00:00:00")
Vote 146
146 views
7m
Jan 3, 2022
G
An overly detailed analysis of a bad DateTime comparison in C#
if (DateTime.Now.ToString() == "01/01/2022 00:00:00")
{
Console.WriteLine("Happy New Year!");
}
else
{
Console.WriteLine("It's still 2021…");
}
About Scott Hanselman
I'm a teacher. I speak all over to whomever will listen. I have written code that you've likely used. I've been blogging for over a decade and podcasting for about half that. I speak, code, write, empower, promote, learn and listen.

05:02
Solar Pergola Upgrade
2 days ago

06:03
Standing Mailbag Bench
2 days ago

05:37
Ekster Wallets
3 days ago

00:58
The Cursed Dual Floppy Mac 512K Lives!
3 days ago
0 Comments