Converting datetime to Javascript milliseconds in epoch
Useful for transferring datetime values to JS: briefer and overcoming the 1 vs. 0 based month enumeration difference between python and JS.
- datetime
- time
- api
- seconds
- epoch
Useful for transferring datetime values to JS: briefer and overcoming the 1 vs. 0 based month enumeration difference between python and JS.
This is useful when you need to convert a datetime.datetime.now() or datetime.date.today() into a unix epoch seconds, with microsecond precision (precision only applies to datetime.datetime, as datetime.date won't have any microseconds). I have found this is necessary for when storing the DateTime in the models as a FloatField, in order to keep the usec/microsecond precision. At some point, I will probably create a custom model field called DateTimeWithUSec or something like that, but for now, this will do :)