Opened 6 years ago
Last modified 22 months ago
#46210 new enhancement
Add helpers for default/empty datetime value
Reported by: | johnjamesjacoby | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | Database | Keywords: | has-patch |
Focuses: | Cc: |
Description
Typing 0000-00-00 00:00:00
is error prone, and tedious.
There are a few dozen usages of it sprinkled through-out WordPress. Hundreds of plugins also.
I offer up the idea of 2 helper functions:
__return_empty_datetime()
that simply returns0000-00-00 00:00:00
is_empty_datetime( $datetime = '' )
to check if a variable isempty()
or0000-00-00 00:00:00
Change History (5)
#2
@
6 years ago
- Component changed from Date/Time to Database
- Keywords needs-patch added; 2nd-opinion removed
- Type changed from defect (bug) to enhancement
+1
#3
@
5 years ago
Somewhat related to #41785...
If there were such a helper function, it could include a MySQL version check, and own the default return value based on that and whatever MySQL modes happen to be set.
This ticket was mentioned in Slack in #core by jjj. View the logs.
4 years ago
This ticket was mentioned in PR #4130 on WordPress/wordpress-develop by @tabrisrp.
22 months ago
#5
- Keywords has-patch added; needs-patch removed
Add helper functions for default datetime value and check for empty datetime value.
Trac ticket: https://core.trac.wordpress.org/ticket/46210
Note: See
TracTickets for help on using
tickets.
Beware: the
NO_ZERO_DATES
MySQL mode rabbit hole is very deep.WordPress doesn't use null as a default value in
datetime
columns for legacy reasons, and I'm not suggesting we try to support it here. Mostly, I am just sick of typing0000-00-00 00:00:00
in my own related code, and rewriting the same helpers for avoiding empty datetime values.