below is the Scenario:
1. (Host-machine)User will create tasks on the server by sending task information to the rest services of server (task_name,task_owner etc)
2. (server-machine)server will receive information from the user and creates a timestamp(2017-08-07 08:42:07-04:00) along with timezone for the task and saves into a database
3. user will do list tasks and user must be able to see task_name,task_owner and task_creation time
Assuming Host-machine and server-machine are on different timezones.
when user does list tasks we trigger the rest-services and processes the tasks timestamps and show local timestamps equivalent to server timezone.
我的主機的機器代碼使用Python來觸發REST的服務和解析結果..從服務器獲取的時間戳本地時間戳
so,
input: 2017-08-07 08:42:07-04:00
output : 2017-08-07 17:30:03
explanation: its converting from time stamp of one time zone to
another timezone.EDT is 2017-08-07 08:42:07-04:00
IST is 2017-08-07 08:42:07+5:30 .
so, assume Local is IST the time must be ~17:30
(8:42:07+9:30)
新蜂到Python幫我出:)
的可能的複製[?如何轉換字符串日期時間在Python時間戳(https://stackoverflow.com/questions/10957522/how-to-convert-字符串日期時間到時間戳在蟒蛇) – Thomas
@ThomasMey這不是一個重複!因爲您共享的帖子將字符串轉換爲同一時間+偏移量的時間戳對象。但我的問題是從一個時區的時間戳轉換到另一個時區。 EDT是2017-08-07 08:42:07-04:00 IST是2017-08-07 08:42:07 + 5:30。可以說本地是IST,時間一定是〜9:30(8 :42:07 + 9:30)。 python中有沒有這樣的方法來實現這個用例? –
任何人都知道答案的答案..這將是偉大的!提前致謝。 –