Arrow is a python library and command-line tool to genrerate, manipulate dates, times, timestamps.

use of arrow:

With the use of arrow, we can also create, manipulate, format and convert dates, times, and timestamps, convert timezones, generates time spans, ranges, floors and ceilings  with a less code.

Installation:

We can install arrow using the pip command.

  pip install arrow

Arrow Functions:

Creating Date and time:

To get the UTC time:

import arrow

utc = arrow.utcnow()

Here UTC will give date and time, utc.year will give year value, utc.date() will dive only date object, a.time() will give only time

To Convert into specific timezone with a specific format:

arrow.utcnow().to('Asia/Calcutta').format('YYYY-MM-DD HH:mm:ss'),

To convert date time object into arrow object with specific time zone:

arrow.get(b).to('Asia/Calcutta')
arrow.get('2013-05-05 12:30:45', 'YYYY-MM-DD HH:mm:ss')

To replace the date time, we can use replace function with hours, minutes, seconds attribute:

arrow.get(b).to(inst.timezone.name).replace(hours=24).format('YYYY-MM-DD HH:mm:ss')

arrow.replace(year=2016, month=2)

arw.replace(weeks=+2)

To get the time difference in words, we can use the below function:

arrow.humanize()

Subscribe To our news letter

Subscribe to our news letter to receive latest blog posts into your inbox. Please fill your email address in the below form.
*We don't provide your email contact details to any third parties
Latest Comments
Related Articles
Generating PDF Files in Python using xhtml2pdf Siva Chittamuru

There are many ways for generating PDF in python. In this post I will be presenting PDF files generation with xhtml2pdf.

xhtml2pdf: xhtml2pdf is a ...

Continue Reading...
Working with python collections part 2 Rakesh babu Podishetty

Python collections - Counter is to count the frequency of character, OrderedDict is to track the order of the contents in which they are added ...

Continue Reading...
Export Data with Scrapy python Jagadeesh V

In previous post we collected top 250 movies names and their links from imDb. In this blog post, lets look into exporting that data into ...

Continue Reading...