@@ -737,18 +737,16 @@ Instance methods:
737
737
.. method :: date.strftime(format)
738
738
739
739
Return a string representing the date, controlled by an explicit format string.
740
- Format codes referring to hours, minutes or seconds will see 0 values. For a
741
- complete list of formatting directives, see
742
- :ref: `strftime-strptime-behavior `.
740
+ Format codes referring to hours, minutes or seconds will see 0 values.
741
+ See also :ref: `strftime-strptime-behavior ` and :meth: `date.isoformat `.
743
742
744
743
745
744
.. method :: date.__format__(format)
746
745
747
746
Same as :meth: `.date.strftime `. This makes it possible to specify a format
748
747
string for a :class: `.date ` object in :ref: `formatted string
749
- literals <f-strings>` and when using :meth: `str.format `. For a
750
- complete list of formatting directives, see
751
- :ref: `strftime-strptime-behavior `.
748
+ literals <f-strings>` and when using :meth: `str.format `.
749
+ See also :ref: `strftime-strptime-behavior ` and :meth: `date.isoformat `.
752
750
753
751
Examples of Usage: :class: `date `
754
752
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -1051,8 +1049,8 @@ Other constructors, all class methods:
1051
1049
1052
1050
:exc: `ValueError ` is raised if the date_string and format
1053
1051
can't be parsed by :func: `time.strptime ` or if it returns a value which isn't a
1054
- time tuple. For a complete list of formatting directives, see
1055
- :ref: ` strftime-strptime-behavior `.
1052
+ time tuple. See also :ref: ` strftime-strptime-behavior ` and
1053
+ :meth: ` datetime.fromisoformat `.
1056
1054
1057
1055
1058
1056
@@ -1510,20 +1508,21 @@ Instance methods:
1510
1508
(which :func: `time.ctime ` invokes, but which
1511
1509
:meth: `datetime.ctime ` does not invoke) conforms to the C standard.
1512
1510
1511
+
1513
1512
.. method :: datetime.strftime(format)
1514
1513
1515
- Return a string representing the date and time, controlled by an explicit format
1516
- string. For a complete list of formatting directives, see
1517
- :ref: `strftime-strptime-behavior `.
1514
+ Return a string representing the date and time,
1515
+ controlled by an explicit format string.
1516
+ See also :ref: `strftime-strptime-behavior ` and :meth: ` datetime.isoformat `.
1518
1517
1519
1518
1520
1519
.. method :: datetime.__format__(format)
1521
1520
1522
1521
Same as :meth: `.datetime.strftime `. This makes it possible to specify a format
1523
1522
string for a :class: `.datetime ` object in :ref: `formatted string
1524
- literals <f-strings>` and when using :meth: `str.format `. For a
1525
- complete list of formatting directives, see
1526
- :ref: ` strftime-strptime-behavior `.
1523
+ literals <f-strings>` and when using :meth: `str.format `.
1524
+ See also :ref: ` strftime-strptime-behavior ` and :meth: ` datetime.isoformat `.
1525
+
1527
1526
1528
1527
Examples of Usage: :class: `.datetime `
1529
1528
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -1868,17 +1867,15 @@ Instance methods:
1868
1867
.. method :: time.strftime(format)
1869
1868
1870
1869
Return a string representing the time, controlled by an explicit format
1871
- string. For a complete list of formatting directives, see
1872
- :ref: `strftime-strptime-behavior `.
1870
+ string. See also :ref: `strftime-strptime-behavior ` and :meth: `time.isoformat `.
1873
1871
1874
1872
1875
1873
.. method :: time.__format__(format)
1876
1874
1877
- Same as :meth: `.time.strftime `. This makes it possible to specify a format string
1878
- for a :class: `.time ` object in :ref: `formatted string
1879
- literals <f-strings>` and when using :meth: `str.format `. For a
1880
- complete list of formatting directives, see
1881
- :ref: `strftime-strptime-behavior `.
1875
+ Same as :meth: `.time.strftime `. This makes it possible to specify
1876
+ a format string for a :class: `.time ` object in :ref: `formatted string
1877
+ literals <f-strings>` and when using :meth: `str.format `.
1878
+ See also :ref: `strftime-strptime-behavior ` and :meth: `time.isoformat `.
1882
1879
1883
1880
1884
1881
.. method :: time.utcoffset()
@@ -2320,6 +2317,14 @@ versus :meth:`strptime`:
2320
2317
:meth: `strftime ` and :meth: `strptime ` Format Codes
2321
2318
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2322
2319
2320
+ These methods accept format codes that can be used to parse and format dates::
2321
+
2322
+ >>> datetime.strptime('31/01/22 23:59:59.999999',
2323
+ ... '%d/%m/%y %H:%M:%S.%f')
2324
+ datetime.datetime(2022, 1, 31, 23, 59, 59, 999999)
2325
+ >>> _.strftime('%a %d %b %Y, %I:%M%p')
2326
+ 'Mon 31 Jan 2022, 11:59PM'
2327
+
2323
2328
The following is a list of all the format codes that the 1989 C standard
2324
2329
requires, and these work on all platforms with a standard C implementation.
2325
2330
0 commit comments