Relative Content

Tag Archive for c#datetime

DateTime ParseExact throws FormatException for only PM times

I have a list of different DateTime formats and I want to convert all of them in one specific format. It works fine, until I hit this line: 9.13.2023 2:06:58 PM. On this line i get an System.FormatException. But the line 9.13.2023 6:38:50 AM works fine. Do i overlook something?

DateTime not returning Time portion

I have a string that I’m trying to convert into a 24hr DateTime. So far the closest thing I’ve found to work is doing a substring on the values and then creating a new DateTime using those values. However, even though in Debug I can see it’s setting hours, minutes, seconds, the value returned is just the Date and not the DateTime. Am I missing something to accommodate returning Date and Time?

C# specify kind on date

i am trying to work on getting data based on start and end date but i keep getting an error each time, this is what i have

how to make time changes while the compiler is running?

I am trying to generate random prime numbers without using stand() or rand() functions. I want to generate random numbers with the function that generates time in seconds as random values then check if it’s prime or not if it’s not prime then run the function that generates time again with different values.
The code gets me a Segmentation fault while its not prime 🙁