Display time or date in list view

Status
Not open for further replies.

aclertant

dedlefou
Hello,

The Date element work pretty well for me, against all the post I found about it ;o)

What I want to do is displaying just the time (hh:mm) for records corresponding to the current day.

And displaying just the date (dd:mm:yy) when the record is older then the current day.

Example : We are "SUNDAY 5 December 2012" my list view should look like this

1) 12:30
2) 11:30
3) 4/Dec/2012
4) 3/Nov/2012

1 and 2 was recorded today while 3 + 4 was recorded before today

I hope everythings is clear ?
And I hope its simple to do ;)

Thank's a lot, and keep this good job going !
Andr?.
 
It could be possible using 2 different fields - types DATE and TIME in your database table instead of one single DATETIME field. Then you would need Birthday element on date field and Time element on time field. If you don't have them you can download them from github. Then you can group data by date in list view... and the rest you may discover by yourself :)
 
Hello Jaanus,

Thanks for your reply.

My date element finaly become a timestamp element... Because I need it to be updated in inline update list and this way it work fine.

I think I will have to create a php function in the template list rendering.
 
You can use an additional "display" element (hidden in form, show in list view), eval enabled and php code in "default" returning the content of your date/time/timestamp element in the format you want.
 
Hello Troester,

When speaking about Time, swiss guys are never far ;)

Your solution is fine. I added this piece of code in a display element.

PHP:
$timestamp = '{planning___timestamp_element}'; // get auto updated recorded value ex: YYYY-MM-DD HH:MM:SS
$date = date("Y-m-d"); // get current YYYY-MM-dd

if($date == substr($timestamp, 0, 10)){ // substring $timestamp to get : YYYY-MM-dd
$date = substr($timestamp, -8); // if date equal then display HH:MM:SS
}else{
$date = substr($timestamp, 0, 10); // else display YYYY-MM-dd
}

return $date;
It save me to do it inside the template directly.

Thanks a lot, Bye
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top