Sort by custom field – set MySQL date format

If the value (stored in database) of your date custom field is not in kind of Year Month Day format (for example: 1970-01-01 or 1970/01/01), WordPress may not able to sort by that field correctly.

To make it work correctly, please specify MySQL date format of the value (stored in database) of your custom field.

For example:
date value is Jan 01 1970 => date format is %b %d %Y
date value is 1st/01/1970 => date format is %D/%m/%Y
date value is 2020-10-20 => date format is %Y-%m-%d
date value is 1543310966 => date format is _UNIX_TIMESTAMP_ (this custom format is available since Content Views Pro version 5.4.0)

Please check below table to get correct format for each part in your date value.

Value Format
Unix timestamp ( a long number string, for example: 1543310966 ) _UNIX_TIMESTAMP_
Abbreviated weekday name ( Sun.. Sat) %a
Abbreviated month name ( Jan.. Dec) %b
Month, numeric ( 0.. 12) %c
Day of the month with English suffix ( 0th, 1st, 2nd, 3rd, …) %D
Day of the month, numeric ( 00.. 31) %d
Day of the month, numeric ( 0.. 31) %e
Microseconds ( 000000.. 999999) %f
Hour ( 00.. 23) %H
Hour ( 01.. 12) %h
Hour ( 01.. 12) %I
Minutes, numeric ( 00.. 59) %i
Day of year ( 001.. 366) %j
Hour ( 0.. 23) %k
Hour ( 1.. 12) %l
Month name ( January.. December) %M
Month, numeric ( 00.. 12) %m
AM or PM %p
Time, 12-hour ( hh:mm:ss followed by AM or PM) %r
Seconds ( 00.. 59) %S
Seconds ( 00.. 59) %s
Time, 24-hour ( hh:mm:ss) %T
Week ( 00.. 53), where Sunday is the first day of the week; WEEK() mode 0 %U
Week ( 00.. 53), where Monday is the first day of the week; WEEK() mode 1 %u
Week ( 01.. 53), where Sunday is the first day of the week; WEEK() mode 2; used with %X %V
Week ( 01.. 53), where Monday is the first day of the week; WEEK() mode 3; used with %x %v
Weekday name ( Sunday.. Saturday) %W
Day of the week ( 0=Sunday.. 6=Saturday) %w
Year for the week where Sunday is the first day of the week, numeric, four digits; used with %V %X
Year for the week, where Monday is the first day of the week, numeric, four digits; used with %v %x
Year, numeric, four digits %Y
Year, numeric (two digits) %y
A literal % character %%
x, for any x not listed above % x

Source: https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-format