我有一个sublimitext3的插件,它为我提供了新文档的时间戳。一切正常,但我拨错时区了。我是东部时间,但它为我提供了提前6小时(UTC)的时间。在
import sublime, sublime_plugin
from datetime import datetime
class TimestampCommand(sublime_plugin.TextCommand):
def run(self, edit):
stamp = datetime.utcnow().strftime("%A %B %d, %Y | %H:%M:%S")
for r in self.view.sel():
if r.empty():
self.view.insert (edit, r.a, stamp)
else:
self.view.replace(edit, r, stamp)
尝试
stamp = datetime.now().strftime("%A %B %d, %Y | %H:%M:%S")
日期时间。现在()提供您的本地时间。在
相关问题 更多 >
编程相关推荐