function CourseObjectAttendance::secondsToInterval in Course 3.x
Convert seconds to full ISO8601 string.
Yes, we can use DateInterval but Duration expects a full string (not just PT100S).
Why isn't this a thing?
1 call to CourseObjectAttendance::secondsToInterval()
- CourseObjectAttendance::optionsForm in modules/
course_attendance/ src/ Plugin/ course/ CourseObject/ CourseObjectAttendance.php - Default options form for all course objects.
File
- modules/
course_attendance/ src/ Plugin/ course/ CourseObject/ CourseObjectAttendance.php, line 195
Class
- CourseObjectAttendance
- Plugin annotation @CourseObject( id = "attendance", label = "Attendance", )
Namespace
Drupal\course_attendance\Plugin\course\CourseObjectCode
function secondsToInterval($seconds) {
$date1 = new \DateTime('1904-01-01');
$date2 = new \DateTime('1904-01-01');
$date2
->add(new \DateInterval("PT{$seconds}S"));
return $date2
->diff($date1);
}