Skip to content

Script: GoodMorning

SamuelPlentz edited this page Feb 5, 2020 · 1 revision

This script creates a dynamic greeting depending on the current time.

Script

var date = new Date();
if (date.getHours() <  5) return "Good night";
if (date.getHours() < 12) return "Good morning";
if (date.getHours() < 16) return "Good afternoon";
if (date.getHours() < 21) return "Good evening";

return "Good night";

Usage

This script in your template:

[[SCRIPT=GoodMorning]]

would resolve to: Good morning, Good afternoon, Good evening or Good night depending on the current time.