Re: [northernpenguin] createdDate for Multi-Record Tables
Hi northernpenguin,
createdDates can be compared easily enough to find the most recent update, but you can also change the order in which multiple records are pulled from the table so that the most recent is first (or last, as needed) and that way you know exactly where in the results array the record (and createdDate) are located.
To set the sort order of a multi-record table, click on Admin->Section Editors->[Appropriate Section]->Sorting and then add the desired sort pattern (in this case, "createdDate DESC").
Now when the records are retrieved the most recent record will be first (position 0).
If you already have a sort and can't use the above method, you can compare createdDates using the following:
list($records, $recordsMetaData) = getRecords(array(
'tableName' => 'multiRecordsTable',
));
// Set variable to store createdDate
$mostRecentCreatedDate = 0; // technically this date is Dec 31, 1969 - the beginning of the Unix epoch
// Go through each returned record and find the most recent createdDate
foreach ( $records as $record ) {
$createdDateAsTimeStamp = strtotime($record['createdDate']);
if ( $createdDateAsTimeStamp > $mostRecentCreatedDate ) { $mostRecentCreatedDate = $createdDateAsTimeStamp; }
}
Now you can print or echo the variable $mostRecentCreatedDate as the most recent updated record date.
Hope this helps,
Tom