Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
54afa550
Commit
54afa550
authored
Apr 25, 2011
by
Alexander Belopolsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #2736: Documented how to compute seconds since epoch.
parent
c1935d2a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
0 deletions
+16
-0
Doc/library/datetime.rst
Doc/library/datetime.rst
+16
-0
No files found.
Doc/library/datetime.rst
View file @
54afa550
...
@@ -721,6 +721,22 @@ Other constructors, all class methods:
...
@@ -721,6 +721,22 @@ Other constructors, all class methods:
It's common for this to be restricted to years in 1970 through 2038. See also
It's common for this to be restricted to years in 1970 through 2038. See also
:meth:`fromtimestamp`.
:meth:`fromtimestamp`.
On the POSIX compliant platforms, ``utcfromtimestamp(timestamp)``
is equivalent to the following expression::
datetime(1970, 1, 1) + timedelta(seconds=timestamp)
There is no method to obtain the timestamp from a :class:`datetime`
instance, but POSIX timestamp corresponding to a :class:`datetime`
instance ``dt`` can be easily calculated as follows. For a naive
``dt``::
timestamp = (dt - datetime(1970, 1, 1)) / timedelta(seconds=1)
And for an aware ``dt``::
timestamp = (dt - datetime(1970, 1, 1, tzinfo=timezone.utc)) / timedelta(seconds=1)
.. classmethod:: datetime.fromordinal(ordinal)
.. classmethod:: datetime.fromordinal(ordinal)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment