mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-03 01:39:24 +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);
|
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
|
* @param string $time
|
||||||
|
@ -240,4 +261,4 @@ function parseToFloat($numString) {
|
||||||
|
|
||||||
// Convert to float
|
// Convert to float
|
||||||
return (float) $numString;
|
return (float) $numString;
|
||||||
}
|
}
|
||||||
|
|
|
@ -403,9 +403,7 @@ function createGallerySectionVideo($video, $showChannel = true, $screenColsLarge
|
||||||
?>
|
?>
|
||||||
<?php
|
<?php
|
||||||
if (!empty($advancedCustom->showCreationTimeOnVideoItem)) {
|
if (!empty($advancedCustom->showCreationTimeOnVideoItem)) {
|
||||||
$humanTiming = $advancedCustom->showHumanTimingOnVideoItem
|
$humanTiming = humanTimingOrDate($video['videoCreation'], 0, true, true);
|
||||||
? humanTiming(strtotime($video['videoCreation']), 0, true, true)
|
|
||||||
: date('Y-m-d H:i', strtotime($video['videoCreation']));
|
|
||||||
?>
|
?>
|
||||||
<time datetime="<?php echo $video['videoCreation']; ?>" class="videoHumanTime pull-right">
|
<time datetime="<?php echo $video['videoCreation']; ?>" class="videoHumanTime pull-right">
|
||||||
<i class="far fa-clock"></i>
|
<i class="far fa-clock"></i>
|
||||||
|
|
|
@ -13,7 +13,7 @@ if (is_array($video)) {
|
||||||
//var_dump(__LINE__, !empty($advancedCustom->showCreationTimeOnVideoItem));exit;
|
//var_dump(__LINE__, !empty($advancedCustom->showCreationTimeOnVideoItem));exit;
|
||||||
if (!empty($advancedCustom->showCreationTimeOnVideoItem)) {
|
if (!empty($advancedCustom->showCreationTimeOnVideoItem)) {
|
||||||
$created = !empty($video['videoCreation']) ? $video['videoCreation'] : $video['created'];
|
$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 {
|
} else {
|
||||||
$html = '<!-- empty showCreationTimeOnVideoItem ' . basename(__FILE__) . ' line=' . __LINE__ . '-->';
|
$html = '<!-- empty showCreationTimeOnVideoItem ' . basename(__FILE__) . ' line=' . __LINE__ . '-->';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue