View file system/inc/classes/timedate.class.php

File size: 2.4Kb
<?php
/**
 * Устаревщий вид класса 
 * @CMS SHCMS Engine
 * @copyright Shamsik © 2012
 */
 
class timed
{
    private $timep;
	private $time_post;
	
    function times($time = NULL)
	{
	
	/*
     * Получение читабельного представления времени
     */
    global $time_post;
    
	if ($line_time==NULL)
	{
	  $line_time=time();
	}
	
    if (isset($this->time_post))
            $time = $time + $this->time_post['time']*60*60;
            $this->timep = date("j M Y в H:i", $time)."";
            $time_en[0]=date("j n Y", $time);
            $time_en[1]=date("H:i:s", $time);
			
    if ($time_en[0]==date("j n Y"))
            $this->timep= date("H:i:s", $time);
			
    if (isset($this->time_post))
	{
    if ($time_en[0] == date("j n Y", time()+$this->time_post['time']*60*60))
            $this->timep=date("H:i:s", $time);
			
    if ($time_en[0] == date("j n Y", time()-60*60*(24-$this->time_post['time'])))
            $this->timep="Вчера в $time_en[1]";}
    else {
	
    if ($time_en[0] == date("j n Y"))
            $this->timep = 'Сегодня в '.date("H:i:s", $time);
			
    if ($time_en[0] == date("j n Y", time()-60*60*24))
            $this->timep="Вчера в $time_en[1]";
		}
	/*
     * Преобразования времени с ENG на RUS
     */
            $times = array();
            $times[0] = 'Jan';
            $times[1] = 'Feb';
            $times[2] = 'Mar';
            $times[3] = 'May';
            $times[4] = 'Apr';
            $times[5] = 'Jun';
            $times[6] = 'Jul';
            $times[7] = 'Aug';
            $times[8] = 'Sep';
            $times[9] = 'Oct';
            $times[10] ='Nov';
            $times[11] = 'Dec';
            $time_ob = array();
            $time_ob[0] = 'Янв';
            $time_ob[1] = 'Фев';
            $time_ob[2] = 'Марта';
            $time_ob[3] = 'Мая';
            $time_ob[4] = 'Апр';
            $time_ob[5] = 'Июня';
            $time_ob[6] = 'Июля';
            $time_ob[7] = 'Авг';
            $time_ob[8] = 'Сент';
            $time_ob[9] = 'Окт';
            $time_ob[10] = 'Ноября';
            $time_ob[11] = 'Дек';
            $time_result = str_replace($times,$time_ob,$this->timep);
			
        return $time_result;
	}
}


$timedate = new timed;

?>