[Answer]-Converting time string to TimeField

1👍

The TimeField field is not used to save and/or express an amount of time, like “x seconds”, but a time in the day, like saying “X event occurred at 03:00:00”; here, “03:00:00” is the value for TimeField. Namely you might see it as the time part of a datetime.datetime object.

If what you need to store is an amount of time, you can use any other built-in field (IntegerField, CharField, etc) that fits your needs and manipulate it yourself.

Depending on what you need the value for, django-timedeltafield or DurationField may be useful as well. Although DurationField is only available in django 1.8 at the moment.

I hope this helps! 🙂

👤Gerard

Leave a comment