mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 20:17:24 +08:00
format_datetime() use Carbon::parse()
This commit is contained in:
@@ -41,6 +41,7 @@ use Nexus\Database\NexusDB;
|
|||||||
use Nexus\Imdb\Imdb;
|
use Nexus\Imdb\Imdb;
|
||||||
use NexusPlugin\PostLike\PostLike;
|
use NexusPlugin\PostLike\PostLike;
|
||||||
use NexusPlugin\StickyPromotion\Models\StickyPromotion;
|
use NexusPlugin\StickyPromotion\Models\StickyPromotion;
|
||||||
|
use NexusPlugin\StickyPromotion\Models\StickyPromotionParticipator;
|
||||||
use Rhilip\Bencode\Bencode;
|
use Rhilip\Bencode\Bencode;
|
||||||
|
|
||||||
class Test extends Command
|
class Test extends Command
|
||||||
@@ -76,10 +77,8 @@ class Test extends Command
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$torrent = Torrent::query()->find(2);
|
$r = StickyPromotionParticipator::query()->first();
|
||||||
$torrent = apply_filter('torrent_detail', $torrent);
|
dd($r->created_at);
|
||||||
$user = \App\Models\User::query()->find(10001);
|
|
||||||
do_action('announced', $torrent->toArray(), $user->toArray());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -574,13 +574,13 @@ function last_query($all = false)
|
|||||||
|
|
||||||
function format_datetime($datetime, $format = 'Y-m-d H:i')
|
function format_datetime($datetime, $format = 'Y-m-d H:i')
|
||||||
{
|
{
|
||||||
if ($datetime instanceof \Carbon\Carbon) {
|
try {
|
||||||
return $datetime->format($format);
|
$carbonTime = \Carbon\Carbon::parse($datetime);
|
||||||
|
$carbonTime->format($format);
|
||||||
|
} catch (\Exception) {
|
||||||
|
do_log("Invalid datetime: $datetime", 'error');
|
||||||
|
return $datetime;
|
||||||
}
|
}
|
||||||
if (is_numeric($datetime) && $datetime > strtotime('1970')) {
|
|
||||||
return date($format, $datetime);
|
|
||||||
}
|
|
||||||
return $datetime;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function nexus_trans($key, $replace = [], $locale = null)
|
function nexus_trans($key, $replace = [], $locale = null)
|
||||||
|
|||||||
Reference in New Issue
Block a user