Get UTC time in seconds

bash, date, datetime

Solution

I believe `+%s` is seconds since epoch. It's timezone invariant.

Problem

It looks like I can't manage to get the bash UTC date in second. I'm in Sydney so + 10hours UTC time ``` date Thu Jul 3 17:28:19 WST 2014 date -u Thu Jul 3 07:28:20 UTC 2014 ``` But when I tried to convert it, I'm getting the same result which is not UTC time ``` date +%s 1404372514 date -u +%s 1404372515 ``` What am I missing here? After getting an answer saying `date +%s` was returning UTC time, here are more details about the problem I'm facing now. I'm trying to compare a date written in a file with python. This date is written in seconds in UTC time. And the bash `date +%s` doesn't give me the same one. Actually if I'm doing in python `time.asctime(time.localtime(date_in_seconds_from_bash))`, I get the current time of Sydney, not UTC. I don't understand.

Original source