Date in relative format

Hi,

I’m trying to display the date in relative format. I’m looking at Xojo documentation but I can’t find anything related.

Which is the best way to display date in relative format?

Thank you.

Hi Jose,
There’s nothing built in that I’m aware of, but I do offer GraffitiLocale as part of GraffitiSuite Web and Desktop which can give you relatively formatted date strings by comparison and return something like “1 day ago” or “2 years ago”.

1 Like

WebListBox has a Relative style in it’s WebListBoxDateTimeRenderer see https://documentation.xojo.com/api/user_interface/web/weblistbox.htmlDateTimeRenderer

2 Likes

Its for desktop, so I will try GraffitiSuite.

Thanks.

1 Like

though I have issues reading the date value back, have you found out how to do that? Seems that the renderer is storing a JSON(-esque) file …

{"timestamp":1607209200.0,"tzoffset":0,"dateformat":0,"timeformat":4,"timecalc":0,"_xojo_type":"Xojo-DateTime"}

If I was going to want to read the data I would put it in a celltag when adding the row to the listbox. However timestamp appears to be SecondsFrom1970, so dt As New DateTime(timestamp, New Timezone(tzoffset)) should give you the answer.

2 Likes

Thank you. Yes cell tag would be a good option but I wrote a method for it as I need something else in cell tag for this particular case:

var content As New JSONItem
content.Load( dateStr )
var timestamp as double = content.Value("timestamp").DoubleValue
var foundDate as new dateTime( timestamp )

return foundDate