hexojs / hexo

A fast, simple & powerful blog framework, powered by Node.js.
https://hexo.io
MIT License
39.51k stars 4.86k forks source link

moment.utc is not a function #4315

Closed geekeren closed 4 years ago

geekeren commented 4 years ago

I use moment.utc to format time from UTC string, according to https://hexo.io/zh-cn/docs/helpers.html#moment, so I search momentjs and moment-timezone, so used utc() function to parse it, but failed with following error:

xxxx/hexo-blog/themes/hexo-theme-snippet/layout/_partial/comments.ejs:30
    28|                             } %>
    29|                             <span class="gt-comment-date">
 >> 30|                                 <%= moment.utc(comment.comment_date_gmt).format('YYYY-MM-DD hh:mm') %>
    31|                             </span>
    32|                         </div>
    33|                         <div class="gt-comment-body markdown-body">

moment.utc is not a function

Environment & Settings

Node.js & npm version

v11.15.0

Hexo and Plugin version(npm ls --depth 0)

│ ├── moment@2.25.3
│ ├── moment-timezone@0.5.28
SukkaW commented 4 years ago

moment object can not be use inside template directly.

Only a moment() method is available. Try using moment(date).utc() or sorts of things.