Hi Guys, I'd like a prettier format for the lastModified field. This seems easy, but I can't get it to work. How can I change the complete datetimestamp to DD-MM-YYYY ?
${query[[
from p = index.tag "page"
select { Titel="[["..p.name.."]]" , Date=p.lastModified}
]]}
I use these two small space-lua functions to convert the iso date timestamp string into a more human readable DateTime or only Date:
function humanDateTime(isoStr)
if not isoStr or isoStr == "" or isoStr == "." then return "." end
local date, time = isoStr:match("(%d%d%d%d%-%d%d%-%d%d)T(%d%d:%d%d)")
if date and time then
return date .. " " .. time
end
return isoStr
end
function humanDate(isoStr)
if not isoStr or isoStr == "" or isoStr == "." then return "." end
local date = isoStr:match("(%d%d%d%d%-%d%d%-%d%d)")
if date then
return date
end
return isoStr
end
Example usage: humanDateTime(p.lastModified) ot humanDate(p.lastModified)
this will transfor any isoDateString
e.g.: 2025-12-09T07:53:42.950
into 2025-12-09 07:53 or 2025-12-09
In your queries you can then use:
${query[[
from p = index.tag "page"
select { Titel="[["..p.name.."]]" , Date=humanDateTime(p.lastModified)}
]]}