当节点js当前时间段是早上时,如何显示早上好?

时间:2017-02-15 01:06:02

标签: node.js

当用户进入端口时,节点js应该显示早上好或中午或晚安。

1 个答案:

答案 0 :(得分:0)

const date = new Date().getHours()
date < 12 ? 'Good Morning' : date < 18 ? 'Good Afternoon' : 'Good Night'