Arrow is a python library and command-line tool to genrerate, manipulate dates, times, timestamps.
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.
We can install arrow using the pip command.
pip install arrow
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:
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:
Micropyramid is a software development and cloud consulting partner for enterprise businesses across the world. We work on python, Django, Salesforce, Angular, Reactjs, React Native, MySQL, PostgreSQL, Docker, Linux, Ansible, git, amazon web services. We are Amazon and salesforce consulting partner with 5 years of cloud architect experience. We develop e-commerce, retail, banking, machine learning, CMS, CRM web and mobile applications.
Django-CRM :Customer relationship management based on Django
Django-blog-it : django blog with complete customization and ready to use with one click installer Edit
Django-webpacker : A django compressor tool
Django-MFA : Multi Factor Authentication
Docker-box : Web Interface to manage full blown docker containers and imagesMore...