Skip to content

Instantly share code, notes, and snippets.

@savanovich
Created March 26, 2015 08:00
Show Gist options
  • Save savanovich/e7fe337fcc64ed33a905 to your computer and use it in GitHub Desktop.
Save savanovich/e7fe337fcc64ed33a905 to your computer and use it in GitHub Desktop.
PY: Format datetile in locale
import locale
from datetime import datetime, timedelta
try:
locale.setlocale(locale.LC_TIME, '%s.UTF-8' % lang)
except Exception as e:
logger.error("Error setting exception", lang=lang, exception=e)
# English locale
locale.setlocale(locale.LC_TIME, 'en_US.UTF-8')
result = date_.strftime("%d %b %Y %H:%M")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment