Date and Time


Hello Everyone,

Can anyone please tell me how to print the date and time according to IST?


Friday, 4 May 2018 (UTC+5:30)

Time in India Standard Time

Running this code in the lesson 6 module for Date and Time

from datetime import datetime
now =

print '%s/%s/%s %s:%s:%s' % (now.month,, now.year, now.hour, now.minute, now.second)

give us the time in UTC

5/4/2018 17:38:14

We see from above that India Standard Time is offset by (UTC+5:30) so just add 5:30 to the UTC time.

If your have a Python interactive console it should draw upon your system time and give you the current time for your locale.

>>> from datetime import datetime
>>> now =
>>> now
datetime.datetime(2018, 5, 4, 11, 37, 37, 718768)

In JavaScript we would instantiate a new Date object

 > now = new Date()
<- 2018-05-04T17:44:39.946Z

The above reads in UTC as indicated by the Z which stands for Zulu, the old term used to describe GMT (Greenwich Mean Time)

now = new Date();
hour = now.getHours();
minute = now.getMinutes();

Output for my local time:


Note that the now instance reflects UTC time, whereas the hour and minutes values are my local hour and minute (UTC-6:00).

To determine the offset, we can call the getTimezoneOffset() method which returns the number of minutes difference between UTC and local time.

offset = now.getTimezoneOffset();
// <- 360

In other words, UTC is our time plus 6 hours. Your result might be something like,

-330    *edit: oops!*

meaning UTC is 5 and a half hours behind your local time.