Skip to content

Commit b6d67b7

Browse files
authored
DOC: added example for timezone string for Timestamp.now (#63096)
1 parent 809d9b7 commit b6d67b7

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

pandas/_libs/tslibs/nattype.pyx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1260,7 +1260,9 @@ class NaTType(_NaT):
12601260
Return new Timestamp object representing current time local to tz.
12611261
12621262
This method returns a new `Timestamp` object that represents the current time.
1263-
If a timezone is provided, the current time will be localized to that timezone.
1263+
If a timezone is provided, either through a timezone object or an IANA
1264+
standard timezone identifier, the current time will be localized to that
1265+
timezone.
12641266
Otherwise, it returns the current local time.
12651267
12661268
Parameters
@@ -1279,6 +1281,11 @@ class NaTType(_NaT):
12791281
>>> pd.Timestamp.now() # doctest: +SKIP
12801282
Timestamp('2020-11-16 22:06:16.378782')
12811283
1284+
If you want a specific timezone, in this case 'Brazil/East':
1285+
1286+
>>> pd.Timestamp.now('Brazil/East') # doctest: +SKIP
1287+
Timestamp('2025-11-11 22:17:59.609943-03:00)
1288+
12821289
Analogous for ``pd.NaT``:
12831290
12841291
>>> pd.NaT.now()

pandas/_libs/tslibs/timestamps.pyx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1917,7 +1917,9 @@ class Timestamp(_Timestamp):
19171917
Return new Timestamp object representing current time local to tz.
19181918

19191919
This method returns a new `Timestamp` object that represents the current time.
1920-
If a timezone is provided, the current time will be localized to that timezone.
1920+
If a timezone is provided, either through a timezone object or an IANA
1921+
standard timezone identifier, the current time will be localized to that
1922+
timezone.
19211923
Otherwise, it returns the current local time.
19221924

19231925
Parameters
@@ -1936,6 +1938,11 @@ class Timestamp(_Timestamp):
19361938
>>> pd.Timestamp.now() # doctest: +SKIP
19371939
Timestamp('2020-11-16 22:06:16.378782')
19381940

1941+
If you want a specific timezone, in this case 'Brazil/East':
1942+
1943+
>>> pd.Timestamp.now('Brazil/East') # doctest: +SKIP
1944+
Timestamp('2025-11-11 22:17:59.609943-03:00)
1945+
19391946
Analogous for ``pd.NaT``:
19401947

19411948
>>> pd.NaT.now()

0 commit comments

Comments
 (0)