V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
wizarot
V2EX  ›  分享创造

自己开发的 Sublime 2/3 时间戳插件,时间的相互转换

  •  
  •   wizarot · 2015-06-05 17:56:54 +08:00 · 2963 次点击
    这是一个创建于 3249 天前的主题,其中的信息可能已经有所发展或是发生改变。
    数据库用时间戳记录的.有时候查询到的数据,需要转换过来,每次都写东西,或者去网站挺麻烦的,就写了个简单东西.
    https://github.com/wizarot/sublime_timestamp

    key + tab

    key format example
    now Y-m-d H:i:s 2014-11-22 14:41:54
    tsnow timestamp 140xxxxxxx
    2014-12-22-05-5-23 timestamp 140xxxxxxx

    安装好后,输入 now+tab键, 就转换为当前时间
    tsnow+tab键,转换为当前时间戳
    时间戳+tab键,转换为时间戳对应时间
    2014-12-22-05-5-23+tab键,转换为年月日对应的时间戳.方便写select语句的时间戳条件

    希望有人能喜欢.

    https://github.com/wizarot/sublime_timestamp
    1 条回复    2015-06-23 18:58:37 +08:00
    jiehuangwei
        1
    jiehuangwei  
       2015-06-23 18:58:37 +08:00
    简单的 时间戳 转换插件
    import sublime, sublime_plugin
    import time

    class TestCommand(sublime_plugin.TextCommand):
    def run(self, edit):
    # 1430539200
    # 1430539200
    for sel in self.view.sel():
    t = float(self.view.substr(sel))
    try:
    self.view.replace(edit, sel, time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(t)))
    except:
    pass
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5543 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 06:49 · PVG 14:49 · LAX 23:49 · JFK 02:49
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.