M
M
Mikhail Anc2020-10-22 09:35:30
.NET
Mikhail Anc, 2020-10-22 09:35:30

How to convert datetime to past?

The question is funny, but still,
the date arrives to me as a string 1/15/29, I need to get 1929, but I get 2029...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Developer, 2020-10-22
@samodum

Let's start with the fact that it's impossible.
Guilt on those who send a year without a century.
Kick them and correct the situation on the back.
It's not a front issue.
If there are no options to fix the back, then abandon this crooked API.
PS And if you arrive "1/1/21" or "11/11/20"?.
What year will this be? 1921 or 2021, 1920 or 2020?
How will your code work in three months? And after 9 years? And after 70?

M
mletov, 2020-10-22
@mletov

And how are you going to distinguish the 20th century from the 21st with this format?
And how do you know that it is 1929, and not, for example, 1029?
If, of course, all dates are within the 20th century, then you can forcibly split and add 19 before the year.
But in general, this is a question for the one who gives the data in this form.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question