Arrow is a Python library that offers a sensible, human-friendly approach to dates, times, and timestamps. It aims to be a drop-in replacement for the `datetime` module, providing a more convenient API for creating, manipulating, formatting, and converting dates and times, including robust timezone handling and humanization. The current version is 1.4.0, and it maintains an active release cadence, with updates typically occurring every few months.
pip install arrowVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to get current times, parse date strings, format Arrow objects, perform time shifts, and humanize time differences.
Upgrade Python to version 3.8 or higher. Alternatively, pin Arrow to a version less than 1.3.0 if Python upgrade is not feasible (e.g., `pip install 'arrow<1.3.0'`).
Ensure you are using Arrow version 1.1.1 or higher for reliable `tzinfo` handling with `arrow.get()`. Always verify the timezone of your `Arrow` object using `.tzinfo`.
When interfacing with other libraries that strictly require `datetime.datetime` objects, convert your `Arrow` object using `my_arrow_obj.datetime`.
Whenever possible, prefer creating timezone-aware `Arrow` objects (e.g., `arrow.utcnow()`, `arrow.now(tz='America/New_York')`, or parsing strings with explicit offsets). Use `.to('timezone')` to convert between timezones safely.Install the 'arrow' library using pip: 'pip install arrow'.
Access the 'timestamp' attribute directly: 'arrow_object.timestamp'.
Use the 'format' method: 'arrow_object.format('YYYY-MM-DD')'.Specify the format when parsing a string: 'arrow.get('2023-04-15', 'YYYY-MM-DD')'.Ensure the format string follows Arrow's formatting tokens: 'arrow_object.format('YYYY-MM-DD')'.