Skip to content

Instantly share code, notes, and snippets.

@Sheikh2Imran
Last active December 15, 2019 14:40
Show Gist options
  • Select an option

  • Save Sheikh2Imran/9da3e4701f71eb29b86ca889eae570d1 to your computer and use it in GitHub Desktop.

Select an option

Save Sheikh2Imran/9da3e4701f71eb29b86ca889eae570d1 to your computer and use it in GitHub Desktop.
Convert date object into a desired format (Ex- 16-12-2019)
import time
from django.utils import timezone
now_time = timezone.now().timetuple()
formatted_time = time.strftime("%d-%m-%Y %H:%M:%S", now_time)
print(formatted_time) # it will print '15-12-2019 10:49:54'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment