If that's true it'll work, otherwise it's as much use as a chocolate fireguard lol
Hub Time/World Clock Driver with optional date
metadata {
definition(
name: "HTML Clock Tile",
namespace: "John Williamson",
author: "John Williamson with ChatGPT"
) {
capability "Sensor"
attribute "html", "string"
attribute "version", "string"
}
preferences {
input(
name: "timezone",
type: "enum",
title: "Time Zone",
options: [
"hub":"Hub Time (Hubitat)",
"UTC":"UTC",
"GMT-12":"GMT-12 (IDLW - Baker Island)",
"GMT-11":"GMT-11 (SST - Pago Pago)",
"GMT-10":"GMT-10 (HST - Honolulu)",
"GMT-9":"GMT-9 (AKST - Anchorage)",
"GMT-8":"GMT-8 (PST - Los Angeles)",
"GMT-7":"GMT-7 (MST - Denver)",
"GMT-6":"GMT-6 (CST - Chicago)",
"GMT-5":"GMT-5 (EST - New York)",
"GMT-4":"GMT-4 (AST - Santiago)",
"GMT-3":"GMT-3 (BRT - São Paulo)",
"GMT-2":"GMT-2 (GST - South Georgia)",
"GMT-1":"GMT-1 (CVT - Cape Verde)",
"GMT+0":"GMT+0 (GMT - London)",
"GMT+1":"GMT+1 (CET - Paris)",
"GMT+2":"GMT+2 (EET - Athens)",
"GMT+3":"GMT+3 (MSK - Moscow)",
"GMT+4":"GMT+4 (GST - Dubai)",
"GMT+5":"GMT+5 (PKT - Karachi)",
"GMT+5:30":"GMT+5:30 (IST - Delhi)",
"GMT+6":"GMT+6 (BST - Dhaka)",
"GMT+7":"GMT+7 (ICT - Bangkok)",
"GMT+8":"GMT+8 (CST/SGT - Singapore)",
"GMT+9":"GMT+9 (JST - Tokyo)",
"GMT+10":"GMT+10 (AEST - Sydney)",
"GMT+11":"GMT+11 (SBT - Solomon Islands)",
"GMT+12":"GMT+12 (NZST - Auckland)"
],
defaultValue: "hub"
)
input(
name: "hourFormat",
type: "enum",
title: "Hour Format",
options: ["12":"12-hour","24":"24-hour"],
defaultValue: "24"
)
input(
name: "refreshInterval",
type: "enum",
title: "Refresh Interval (seconds)",
options: ["10":"10","20":"20","30":"30","60":"60"],
defaultValue: "30"
)
input(
name: "dateFormat",
type: "enum",
title: "Date Display",
options: [
"none":"Time only",
"EEE, d MMM yyyy":"Fri, 17 Apr 2026",
"EEEE, d MMMM yyyy":"Friday, 17 April 2026",
"dd/MM/yyyy":"17/04/2026",
"MM/dd/yyyy":"04/17/2026",
"yyyy-MM-dd":"2026-04-17",
"yyyy/MM/dd":"2026/04/17",
"dd-MM-yyyy":"17-04-2026",
"dd MMM yyyy":"17 Apr 2026",
"MMM dd, yyyy":"Apr 17, 2026",
"custom":"Custom"
],
defaultValue: "none"
)
input(
name: "customDateFormat",
type: "string",
title: "Custom Date Format (Java pattern)",
defaultValue: ""
)
}
}
def installed() {
state.version = "1.1 beta"
sendEvent(name: "version", value: state.version)
updateTime()
}
def updated() {
state.version = "1.1 beta"
sendEvent(name: "version", value: state.version)
updateTime()
}
def updateTime() {
def tz = (settings.timezone == "hub" || !settings.timezone) ?
location.timeZone :
TimeZone.getTimeZone(settings.timezone)
def now = new Date()
def timeFormat = settings.hourFormat == "12" ? "h:mm a" : "HH:mm"
def timeStr = now.format(timeFormat, tz)
def dateStr = ""
if (settings.dateFormat && settings.dateFormat != "none") {
def datePattern = settings.dateFormat == "custom" ?
settings.customDateFormat :
settings.dateFormat
if (datePattern) {
dateStr = now.format(datePattern, tz)
}
}
if (dateStr) {
timeStr = dateStr + " " + timeStr
}
sendEvent(name: "html", value: timeStr)
sendEvent(name: "version", value: state.version)
def interval = (settings.refreshInterval ?: "30") as Integer
runIn(interval, updateTime)
}