Skip to main content

UnixDateTimeField in Django

Project description

Provides a UnixDateTimeField to represent date and time stored as Unix time, http://en.wikipedia.org/wiki/Unix_time, at the database level.

I have found it useful quite often when working with legacy systems.

Usage

First you’ll need to attach a UnixDateTimeField to your model. This acts as a the equivalence of a Django PositiveIntegerField at the database level but provides a Django DateTimeField at the ORM abstraction layer.

Example model:

from django_unixdatetimefield import UnixDateTimeField

class MyModel(models.Model):
        created_at = UnixDateTimeField()

Python ORM query:

>>> m = MyModel()
>>> m.created_at = datetime.datetime(2015, 2, 21, 19, 38, 32, 209148)
>>> m.save()

Database:

sqlite> select created_at from mymodel;
1426967129

Installation

Install it with pip (or easy_install):

pip install django-unixdatetimefield

License

BSD, just as the main Django project. See LICENSE file in root of this repo.

Contributing

This project accepts contributions via GitHub pull requests.

Project details


Download files

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

Source Distribution

django-unixdatetimefield-0.1.1.tar.gz (3.2 kB view details)

Uploaded Source

File details

Details for the file django-unixdatetimefield-0.1.1.tar.gz.

File metadata

File hashes

Hashes for django-unixdatetimefield-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b0406a64aebfcf409c7376afb17d945e7d24cc3dc23dd2e2ae89b41238c7ba3a
MD5 2aee5a56c7d773ea450bde64d7c4c2a4
BLAKE2b-256 7e95124bf1b062841302d4b787badb4db5daebfb1edd4d354c75af8458f36a69

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page