推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
python30
V2EX  ›  Python

django 的 时间过滤器 | 输出如下格式的时间: 2020-03-18T09:55:47

  •  
  •   python30 · Mar 19, 2020 · 2117 views
    This topic created in 2257 days ago, the information mentioned may be changed or developed.
    django 的 时间过滤器 | 输出如下格式的时间:2020-03-18T09:55:47

    代码: {{pubdate|date:"Y-m-dTH:i:s"}} 怎么成了: 2020-03-18CST09:55:47

    这个 T 自动转换成 CST 了

    怎么把这个时间换成 2020-03-18T09:55:47 格式?
    5 replies    2020-03-19 17:28:51 +08:00
    wuwukai007
        1
    wuwukai007  
       Mar 19, 2020
    转义了 \T
    T 表示本机所在的时区
    Hstar
        3
    Hstar  
       Mar 19, 2020
    看看文档 https://docs.djangoproject.com/en/3.0/ref/templates/builtins/#date , 说得蛮清楚了

    这字符串会被当做正则处理,T 也是一个关键词,所以要写成 Y-m-d\TH:i:s
    janxin
        4
    janxin  
       Mar 19, 2020
    因为 T 是有意义的,表示 TimeZone...

    你在这里面试试就可以了

    https://docs.djangoproject.com/en/3.0/ref/templates/builtins/#date
    python30
        5
    python30  
    OP
       Mar 19, 2020
    谢谢各位
    OK 了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1017 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 22:58 · PVG 06:58 · LAX 15:58 · JFK 18:58
    ♥ Do have faith in what you're doing.