I am trying to get the values from timespan()
function in Code Igniter. I have one problem, how can I know whether each of the date format is displayed? For example in regards with the codes below, one timespan might be 2 Months, 6 Days, 13 Hours, 14 Minutes
which would have 4 elements but another might be 2 Months, 1 Week, 3 Days, 4 Hours, 39 Minutes
which has 5 elements. If do the preg_replace
then I won't know which are the months or weeks or days etc.
So how do I find out if it is the week or days or hours etc? Because I want to convert the values into cycles like 39mins/1440mins
would be 0.0270833 days, then I will calculate for the hours days weeks months and years and add all of them together
// Hold Cycle Time Conversion
foreach($results as $key => $values)
{
// Convert mysql timestamp to unix
$remove = array('-', ':', ' ');
$hold_timestamp = mysql_to_unix( str_replace( $remove, '', $values['hold_date'] ) );
// Get timespan
$hold_timestamp = timespan($hold_timestamp);
// Explode into arrays
$timestamp_format = explode(',', $hold_timestamp);
// Check each array to get value
foreach($timestamp_format as $ts)
{
$separated_stamp = preg_replace('/[^0-9]/', '', $ts);
/*** Stuck here, incomplete ***/
}
}