-
-
Notifications
You must be signed in to change notification settings - Fork 492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discourage use current_time( 'timestamp' )
#1791
Comments
Just because I missed the emphasis here on first read - the bad thing here isn't the use of |
Yes, |
I'm working on adding this check. I'm inclined to add it to the Opinions ? |
I think (hope) we head towards formally deprecating WP timestamps in the future, so it might make more sense to combine issues related to them as separate sniff. Would make it more convenient down the road to handle them as a separate unit of mess. PS "timestamp" is a single word traditionally in computing context, so |
@Rarst Can you clarify what you mean ? You seem to contradict yourself in yes/no separate sniffs or not. As an alternative, I was just thinking, we could also create a separate So to summarize the choice we have to make for this issue + #1794 :
Either way, looks like the |
Messed up timezones and messed up timestamps are different problems (and So the hierarchy as I see it would go like:
I don't have a strong opinion how that should be organized within PHP CS mechanics. |
@Rarst I just noticed this comment in the Dev docs: https://developer.wordpress.org/reference/functions/current_time/#comment-2373 We may need to find someone with edit rights to Dev docs to remove the comment, or at the very least another comment should be left discrediting the comment. |
Thanks for letting me know, I would probably need to leave bunch of comments around. Will do when new functions are scanned into reference so I can refer to them. |
Is your feature request related to a problem?
current_time()
withtimestamp
orU
format produces a "WordPress timestamp", a sum of Unix timestamp and current time zone offset.While historically entrenched in core, the use of such timestamps is deeply problematic and we are working on eliminating them in favor of real Unix timestamps and full interoperability with PHP.
Describe the solution you'd like
current_time( 'timestamp', true )
/current_time( 'U', true )
are equivalent totime()
and should be replaced with itcurrent_time( 'timestamp' )
/current_time( 'U' )
should be discouraged in favor of requesting non-timestamp format, or otherwise refactoring the usageAdditional context (optional)
The use of
current_time( 'timestamp' )
had been mostly eliminated from core in #40657. Minimal usage in unit tests and older functions that must operate with WP timestamps for backwards compatibility reasons remains.The text was updated successfully, but these errors were encountered: