| Server IP : 104.21.25.182 / Your IP : 216.73.216.141 Web Server : Apache System : Linux server.rehabsharif.com 5.14.0-611.54.3.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:31:24 EDT 2026 x86_64 User : nobi37te ( 1003) PHP Version : 8.2.33 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/nobi37te/public_html/wp-content/plugins/learndash-hub/src/traits/ |
Upload File : |
<?php
namespace Hub\Traits;
/**
* Manipulate the time.
*/
trait Time {
/**
* Sync the timezone from a normal date time string and a date time string with timezone.
*
* @param string $time The normal date time string.
* @param string $time_with_tz The date time string with timezone.
*
* @return int The timestamp
*/
public function sync_timezone( string $time, string $time_with_tz ): int {
$c_datetime = new \DateTime( $time_with_tz );
$b_datetime = new \DateTime( $time, $c_datetime->getTimezone() );
return $b_datetime->getTimestamp();
}
/**
* @param int $timestamp
* @param bool $i18n
*
* @return false|string
*/
public function format_date_time( int $timestamp, bool $i18n = true ) {
$format = get_option( 'date_format' ) . ' ' . get_option( 'time_format' );
if ( false === $i18n ) {
return gmdate( $format, $timestamp );
}
$time = get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $timestamp ), 'Y-m-d H:i:s' );
return date_i18n( $format, strtotime( $time ) );
}
}