Date: 22 May 2023

Module : arrow


Installation : pip install arrow


About:

Arrow is a Python library that offers a human-friendly approach to
creating, manipulating, formatting and converting dates, times and
timestamps. It implements and updates the datetime type, plugging gaps in
functionality and providing an intelligent module API that supports many
common creation scenarios.


Sample:

>>> import arrow

>>> arrow.get('2023-05-11T21:23:58.970460+07:00')

<Arrow [2023-05-11T21:23:58.970460+07:00]>


>>> utc = arrow.utcnow()

>>> utc

<Arrow [2023-05-11T21:23:58.970460+00:00]>


>>> utc = utc.shift(hours=-1)

>>> utc

<Arrow [2023-05-11T20:23:58.970460+00:00]>


>>> local = utc.to('US/Pacific')

>>> local

<Arrow [2023-05-11T13:23:58.970460-07:00]>


>>> local.timestamp()

1368303838.970460


>>> local.format()

'2023-05-11 13:23:58 -07:00'


>>> local.format('YYYY-MM-DD HH:mm:ss ZZ')

'2023-05-11 13:23:58 -07:00'


>>> local.humanize()

'an hour ago'


>>> local.humanize(locale='ko-kr')

'한시간 전'


Reference:

https://pypi.org/project/arrow/
_______________________________________________
Chennaipy mailing list
Chennaipy@python.org
https://mail.python.org/mailman/listinfo/chennaipy

Reply via email to