Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

A easy-use module to solve the datetime needs by string

Project Description

PyTime is a easy-use Python module to solve the common needs of date/time/datetime.

It allows you using string to operate datetime at most situation.PyTime Also provide some simple useful method.


pip install pytime

Simple Usage

Calculate datetime all by string, accept unit for short or overall length, and they can be out of order or in capital:

>>>from pytime import pytime
>>>pytime.before('2015.5.17', '2years 3mon 3d 2hr' )     # 2years 3monhts 3days 2hours before 2015.5.17
datetime.datetime(2013, 2, 13, 22, 0)
>>>pytime.after(pytime.tomorrow(), '23month3dy29minu')   # 23months 3days 29minutes after tomorrow
datetime.datetime(2017, 4, 19, 0, 29)

Parse nonregular datetime string to datetime stamp:

>>>pytime.parse('2015517'), 5, 17)
>>>pytime.parse('5/17/15'), 5, 17)
>>>pytime.parse('92-11-2'), 11, 2)

Get common festivals for single year:

>>>pytime.father()              # Father's Day, 6, 21)
>>>pytime.mother(2016)          # 2016 Mother's Day, 5, 8)
>>>pytime.easter(1999)          # 1999 Easter, 4, 4)

Pytime support calculate between date and datetime, but set the date to midnight:

>>>pytime.count('2015-5-17 23:23:23', pytime.tomorrow())
datetime.timedelta(1, 84203)

Get days between two date, count timedelta by string.

>>>pytime.daysrange('2015-5-17', '2015-5-23')
[, 5, 23),, 5, 22),, 5, 21),, 5, 20),, 5, 19),, 5, 18),, 5, 17)]

and other useful methods for operate datetime easily.



Release History

History Node


History Node


History Node


History Node


History Node


History Node


History Node


This version
History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(6.4 kB) Copy SHA256 Hash SHA256
Source None May 15, 2015

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Kabu Creative Kabu Creative UX & Design Google Google Cloud Servers Fastly Fastly CDN StatusPage StatusPage Statuspage DigiCert DigiCert EV Certificate