2

https://gist.github.com/jordan-brough/4007432を使用して、崇高に動作するタイムスタンプを取得しましたが、時間は 7 時間ずれています。どうすればこれを修正できますか? タイムゾーンを設定する必要がありますか?

import sublime, sublime_plugin
from datetime import datetime

class TimestampCommand(sublime_plugin.TextCommand):
 def run(self, edit):
   stamp = datetime.utcnow().strftime("%m/%d/%y %H:%M %p - ")
   for r in self.view.sel():
    if r.empty():
      self.view.insert (edit, r.a, stamp)
    else:
      self.view.replace(edit, r,   stamp)
4

1 に答える 1

1

に置き換えてみてdatetime.utcnow()くださいdatetime.now()

UTC = タイム オフセットが 0 の協定世界時

于 2013-07-15T08:54:09.140 に答える