Getting time and date in a userfriendly way.

On all sort-by-modified view it’s common to display when the document was modified. This sometimes looks like this:

1
2
3
4
<br />
2006-04-14 14:18    Don't forget to do<br />
2006-04-12 13:33    Latest news about the stuff<br />
2006-03-29 06:49    Sarissa - for me or you?<br />

However, the only time the user can be interested of the timestamp must be if the document is modified today, or perhaps yesterday, if the @modified stamp is older than a day we can be sure that the timestamp is not of any interest. Instead a view like this would serve the user more:

1
2
3
4
<br />
14:18 today Don't forget to do<br />
2006-04-12  Latest news about the stuff<br />
2006-03-29  Sarissa - for me or you?<br />

This can be achieved with this small piece of code:

date2Check := @Modified;
dateFormat := @If(date2Check>@Adjust(@Today;0;0;-1;0;0;0);”D0S3T1″;”D0S0T1″);
date := @Text(date2check;dateFormat);

blog comments powered by Disqus