Created
December 15, 2016 13:33
-
-
Save rafaelhenrique/ee19891bd1b8c24e6bd072fa07559667 to your computer and use it in GitHub Desktop.
Django localized date and time
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pytz | |
from django.utils import timezone | |
local_tz = pytz.timezone('America/Sao_Paulo') | |
datetime_now = timezone.now() | |
localized_date = datetime_now.astimezone(local_tz) | |
date_now = localized_date.strftime('%d%m%Y') # DDMMAAAA | |
time_now = localized_date.strftime('%H%M%S') # HHMMSS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment