Getting epoch time from gmt time stamp

wasp256

I have to calculate the date epoch time from a GMT timestamp, but I'm locally not in that timezone. My current local time is CEST.

So when I try to calculate the epoch time with

date -d "2017-08-05 10:10:10" "+%s"

I get

1501927810

But the given time is a GMT, and should therefore result in

1501927810

I was trying to manually add the difference of hours between the local time and the GMT with

date -d "2017-08-05 10:10:10 +2 hours" "+%F %T"

But that gives me

2017-08-05 11:10:10

why is there only +1 hour added!?

rudimeier

You can tell date to use GMT timezone by setting the environment variable TZ:

$ TZ=GMT date -d "2017-08-05 10:10:10" "+%s"
1501927810

Otherwise you would have to specify the date string as GMT (+0 hours, not 2):

$ date -d "2017-08-05 10:10:10 +0" "+%s"
1501927810

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Get Time stamp using Java GMT+5:30

分類Dev

remove specific characters from time stamp

分類Dev

pulling a time stamp from a txt file

分類Dev

Unix Time stamp creation in C from custom data fields

分類Dev

Can the time stamp of a Retweet be accessed?

分類Dev

epoch nanoseconds to normal time

分類Dev

Generating epoch time in swift

分類Dev

Getting date time stamp difference minutes in Oracle Database 12c Enterprise Edition

分類Dev

How can postgres change from unix epoch time with miliseconds to timestamptz?

分類Dev

converting epoch time from multiple lines in a log file

分類Dev

Coverting epoch time to local time using pandas

分類Dev

Cassandra time stamp returns 0 rows

分類Dev

How to log Serial data with time stamp?

分類Dev

How to stamp prompt at command execute time?

分類Dev

How is the time stamp number in /etc/shadow calculated?

分類Dev

How to find time stamp and decimal value reading from data stream in Java

分類Dev

why Unix Time Stamp for same time is different in different timezone

分類Dev

Getting date/time from DatePicker in swift

分類Dev

Getting real time data from API into route

分類Dev

Getting Epochal Time from Date String

分類Dev

Convert GMT date format to only time format

分類Dev

Convert London Time & Date To GMT +6 Time & Date

分類Dev

Pandas: Check if value is epoch time using python

分類Dev

Is this code returning milliseconds to seconds of epoch time

分類Dev

save epoch time of on column into another column postgres

分類Dev

How to convert Excel date/time to epoch

分類Dev

Ping output - epoch time to human readable

分類Dev

Failed to Convert UTC TIME string date to Epoch time in C#

分類Dev

How to work with a Javascript +Date() numeric time stamp in Python?

Related 関連記事

  1. 1

    Get Time stamp using Java GMT+5:30

  2. 2

    remove specific characters from time stamp

  3. 3

    pulling a time stamp from a txt file

  4. 4

    Unix Time stamp creation in C from custom data fields

  5. 5

    Can the time stamp of a Retweet be accessed?

  6. 6

    epoch nanoseconds to normal time

  7. 7

    Generating epoch time in swift

  8. 8

    Getting date time stamp difference minutes in Oracle Database 12c Enterprise Edition

  9. 9

    How can postgres change from unix epoch time with miliseconds to timestamptz?

  10. 10

    converting epoch time from multiple lines in a log file

  11. 11

    Coverting epoch time to local time using pandas

  12. 12

    Cassandra time stamp returns 0 rows

  13. 13

    How to log Serial data with time stamp?

  14. 14

    How to stamp prompt at command execute time?

  15. 15

    How is the time stamp number in /etc/shadow calculated?

  16. 16

    How to find time stamp and decimal value reading from data stream in Java

  17. 17

    why Unix Time Stamp for same time is different in different timezone

  18. 18

    Getting date/time from DatePicker in swift

  19. 19

    Getting real time data from API into route

  20. 20

    Getting Epochal Time from Date String

  21. 21

    Convert GMT date format to only time format

  22. 22

    Convert London Time & Date To GMT +6 Time & Date

  23. 23

    Pandas: Check if value is epoch time using python

  24. 24

    Is this code returning milliseconds to seconds of epoch time

  25. 25

    save epoch time of on column into another column postgres

  26. 26

    How to convert Excel date/time to epoch

  27. 27

    Ping output - epoch time to human readable

  28. 28

    Failed to Convert UTC TIME string date to Epoch time in C#

  29. 29

    How to work with a Javascript +Date() numeric time stamp in Python?

ホットタグ

アーカイブ