Is it possible to convert a list of local time into UTC?The list of local time is in a text file and I want it to create another text file with a list but in UTC. If possible what command could help

Local time(PST)


2016  03   01  13   15  00

2016  05   12  16   01  22

2016  12   23  09   11  11

Above is a sample format inside of a text file.

  • What I knew UTC = GMT.My time is UTC+7 = GMT+7. London's time is GMT+0
    – supriady
    Jan 6, 2017 at 10:14
  • @supriady London's time is not always GMT, it is BST = GMT+1 during the daylight saving period.
    – jlliagre
    Jan 7, 2017 at 10:45

2 Answers 2


With GNU awk (usually on Linux and sometimes on other systems) and that data you can use

[g]awk '{print strftime(fmt,mktime($0" 0"),1)}' file

If you want output format the same as input, use "%Y %m %d %H %M %S" for fmt. If your input is actually local civil time, including daylight/summer time during the appropriate part of the year, omit the " 0" suffix. If 'PST' is US Pacific zone then it normally follows US rules for daylight time, but if it is Phillipine time it does not normally shift, being near the equator.


The basic command is date. For your first date, you could type in

date -u --date=2016-03-01T13:15:00PST

Of course you want read the text file, so you could do something like

awk '{print "date -u --date="$1"-"$2"-"$3"T"$4":"$5":"$6"PST"}' file.txt | sh

And there are plenty of other ways to process the text file. The man page for date has info on how to format the output.

  • 1
    Requires GNU date.
    – Kusalananda
    Jan 6, 2017 at 10:03
  • It's actually almost achievable with BSD date as well. The %Z specifier to the -f option does not like "PST" as a timezone, though.
    – JdeBP
    Jan 6, 2017 at 11:57
  • 1
    @JdeBP and no --date option.
    – Kusalananda
    Jan 6, 2017 at 12:00
  • I suggest a re-visit of the BSD date manual. The GNU --date option is not a problem. One supplies the input date string to BSD date slightly differently, but it is quite capable of taking dates as input. After all, it wouldn't be a very good command for setting the system clock otherwise. (How not to set the system clock is also explained in the BSD date manual. Indeed, it even has examples of how to do a transformation that is quite close to the one being asked for here. It is only that "PST" isn't a recognized input timezone that is the problem.)
    – JdeBP
    Jan 6, 2017 at 12:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .