How to make the shortest date validator for all formats?

I need to get data and format then return the true or false to check is the passed data have required date-format! for example var_dump(validateDateTime(‘Tue, 28 Feb 2012 12:12:12 +0200’, ‘D, d M Y H:i:s O’)); # the return value should be true I want to validate the date in all formats,by getting the date… Read More How to make the shortest date validator for all formats?

How to separate a sequence of numbers

How can I separate a sequence of numbers of a series in a dataframe like 20191110 into 2019-11-10 using python and pandas? It should be a Date format I tried: df = pd.to_datetime(df.date) But it gave me a complete wrong date. It turned 20191028 into: 1970-01-01 00:00:00.020191028 >Solution : import datetime datetime.datetime.strptime(‘20191110’, "%Y%m%d").date() #output datetime.date(2019,… Read More How to separate a sequence of numbers

Error in Next JS REACT: Objects are not valid as a React child. Just want to use dates

I want to convert this { passagens.departure_date } into date like 1 nov, 2 dez examples. This { passagens.departure_date } is like this value: 2022-10-02T00:00:00Z. I just want to pick the right date in strings. I Try everything. This is my code Also i did the function pegaDia export function pegaDia(str) { var monthNames =… Read More Error in Next JS REACT: Objects are not valid as a React child. Just want to use dates

unsupported operand type(s) for -: 'DateField' and 'DateField'

I am working on creating a contract model with Django and I came cross on how to get the time duration from the start_date to the end_date?? class Contract(models.Model): name = models.CharField(max_length=100) price = models.IntegerField(max_length=10) start_date = models.DateField(auto_now_add=True) end_date = models.DateField(auto_now_add=True) duration = models.IntegerField(end_date – start_date) # how get the duration by hours created_at =… Read More unsupported operand type(s) for -: 'DateField' and 'DateField'