mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-03 09:49:28 +02:00
Implement humanTimingOrDate function for improved video creation time display
This commit is contained in:
parent
0f51d7bc60
commit
c6c664b657
3 changed files with 24 additions and 5 deletions
|
@ -15,6 +15,27 @@ function humanTiming($time, $precision = 0, $useDatabaseTime = true, $addAgo = f
|
|||
return secondsToHumanTiming($time, $precision, $addAgo);
|
||||
}
|
||||
|
||||
function humanTimingOrDate($time, $precision = 0, $useDatabaseTime = true, $addAgo = false){
|
||||
$advancedCustom = getAdvancedCustomizedObjectData();
|
||||
|
||||
if (is_array($time)) {
|
||||
$video = $time;
|
||||
$time = $video['videoCreation'];
|
||||
}
|
||||
|
||||
if (empty($time)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$time = _strtotime($time);
|
||||
|
||||
if (empty($advancedCustom->showHumanTimingOnVideoItem)) {
|
||||
return date('Y-m-d H:i', $time);
|
||||
}
|
||||
|
||||
return humanTiming($time, $precision, $useDatabaseTime, $addAgo);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $time
|
||||
|
|
|
@ -403,9 +403,7 @@ function createGallerySectionVideo($video, $showChannel = true, $screenColsLarge
|
|||
?>
|
||||
<?php
|
||||
if (!empty($advancedCustom->showCreationTimeOnVideoItem)) {
|
||||
$humanTiming = $advancedCustom->showHumanTimingOnVideoItem
|
||||
? humanTiming(strtotime($video['videoCreation']), 0, true, true)
|
||||
: date('Y-m-d H:i', strtotime($video['videoCreation']));
|
||||
$humanTiming = humanTimingOrDate($video['videoCreation'], 0, true, true);
|
||||
?>
|
||||
<time datetime="<?php echo $video['videoCreation']; ?>" class="videoHumanTime pull-right">
|
||||
<i class="far fa-clock"></i>
|
||||
|
|
|
@ -13,7 +13,7 @@ if (is_array($video)) {
|
|||
//var_dump(__LINE__, !empty($advancedCustom->showCreationTimeOnVideoItem));exit;
|
||||
if (!empty($advancedCustom->showCreationTimeOnVideoItem)) {
|
||||
$created = !empty($video['videoCreation']) ? $video['videoCreation'] : $video['created'];
|
||||
$html = '<div class="clearfix"></div><small>' . humanTiming(_strtotime($created)) . '</small>';
|
||||
$html = '<div class="clearfix"></div><small>' . humanTimingOrDate($created) . '</small>';
|
||||
} else {
|
||||
$html = '<!-- empty showCreationTimeOnVideoItem ' . basename(__FILE__) . ' line=' . __LINE__ . '-->';
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue