Skip to content

Timestamp("now") should match to_datetime("now") #18705

Closed
@jbrockmendel

Description

@jbrockmendel

See #17697, #18666

pd.to_datetime('now') returns the current UTC time, while pd.Timestamp('now') returns the current local time. pd.to_datetime('today') rounds the current UTC time down to midnight, while pd.Timestamp('today') returns the current local time (not rounded down). These should be fixed to follow a single convention.

>>> pd.Timestamp('now')
Timestamp('2017-12-09 12:28:31.642416')
>>> pd.to_datetime('now')
Timestamp('2017-12-09 20:28:35')
>>> pd.Timestamp('today')
Timestamp('2017-12-09 12:28:49.263407')
>>> pd.to_datetime('today')
Timestamp('2017-12-09 00:00:00')

AFAICT the to_datetime behavior was designed to match the behavior of np.datetime64('now') and np.datetime64('today'). The Timestamp behavior matches the special constructors Timestamp.now(), Timestamp.today(). At this point I think the least disruptive change would be to make Timestamp(...) behave like to_datetime(...).

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    API - ConsistencyInternal Consistency of API/BehaviorBugDatetimeDatetime data dtypeTimezonesTimezone data dtype

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions