I want to get current time in GMT, like 2015-08-21 05:13:13+00:00
Here you can see that correction is made like 00:00 for GMT, In django they are using from django.utils import timezone
and date_to = timezone.now()
to calculate the current time. How I will get the same functionality in flask, Formate of time should be like 2015-08-21 05:13:13+00:00
not like 2015-03-30 07:19:06.746037+02
. I got this link but they are using 2015-03-30 07:19:06+02
. I don't want. Just GTM time
Following code is in Django, I want same in Flask, Here they are using from django.utils import timezone
. In Flask what is equivalent of it, which gives current time in this format 2015-08-21 05:13:13+00:00
import datetime
import pytz
from django.utils import timezone
def calc_date_args(date_from, date_to, date_options):
try:
date_to = timezone.now()
print 'calc_date_args, date_to', date_to #calc_date_args, date_to 2015-08-21 05:13:13.615541+00:00
date_from = date_to - datetime.timedelta(days=float(date_options))
except Exception:
raise ValueError(_("The time delta must be a number representing "
"the time span in days"))
return date_from, date_to