[issue32988] datetime.datetime.strftime('%s') always uses local timezone, even with aware datetimes

Adam Williamson report at bugs.python.org
Fri Mar 2 20:18:50 EST 2018


Adam Williamson <awilliam at redhat.com> added the comment:

I'd suggest that if that is the case, it would be better for the docs to *specifically mention* that `%s` is not supported and should not be used, rather than simply not mentioning it.

When it's used in real code (note someone in the SO issue mentions "I have been going crazy trying to figure out why i see strftime("%s") a lot, yet it's not in the docs") and just *not mentioned* in the docs, this tends to give the impression that it's something usable that was perhaps just forgotten from the docs, or something. The situation would be much clearer if the docs said "DO NOT USE THIS, IT'S DANGEROUS AND DOESN'T DO WHAT YOU THINK" in big letters. (And suggested using .timestamp() on Python 3.3+, and possibly arrow's .timestamp on 2.7?)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32988>
_______________________________________


More information about the Python-bugs-list mailing list