• 30-08-2012, 15:42:22
    #1
    <?php
    /**
     
     
     */
    class Date {
    
    	/**
    	 * Takes date and time array of values and returns formated string
    	 * @link [http://php.net/manual/en/function.date.php] for compatible format values
    	 *
    	 * @param   array    $datetime  array of date time values to process
    	 * @param   string   $format    format of date to return, default ISO 8601 date
    	 * @return  string
    	 */
    	public static function array_to_string(array $datetime, $format = 'c')
    	{
    		// Extract array variables into scope
    		extract($datetime, EXTR_SKIP);
    
    		// Check month is in the right format
    		$month = date("n", strtotime('01-'.$month.'-'.$year.' 00:00:00'));
    
    		// Created new DateTime object and set the date and time
    		$dt = new DateTime();
    		$dt->setDate($year, $month, $day);
    		$dt->setTime($hour, $minute);
    
    		// Convert all dates to UTC timezone
    		$dt->setTimezone(new DateTimeZone('UTC'));
    
    		// Return correctly formated DateTime string
    		return (string) $dt->format($format);
    	}
    
    	/**
    	 * Converts MySQL datetime in UTC format to local datetime
    	 *
    	 * @param  string  $datetime   UTC date time from database
    	 * @return string
    	 */
    	public static function convert_local($datetime, $format = 'd M Y \a\t G:i T')
    	{
    		$local_dt = new DateTime($datetime, new DateTimeZone('UTC'));
    		$local_dt->setTimezone(new DateTimeZone(date_default_timezone_get()));
    		return (string) $local_dt->format($format);
    	}
    
    	/**
    	 * Tests to see if the datetime supplied from the database record is less than now
    	 *
    	 * @param  string  $datetime   UTC date time from database
    	 * @return boolean
    	 */
    	public static function schedule_missed($datetime)
    	{
    		$now = new DateTime('now', new DateTimeZone('UTC'));
    		$utc_dt = new DateTime($datetime, new DateTimeZone('UTC'));
    
    		return (bool) ($utc_dt < $now);
    	}
    } // END class Date
    date.php dosyasındakı kodlar yukarıda

    init.php de kullandıgım bu

     * @see  http://php.net/timezones
     */
    date_default_timezone_set('TZ=Europe/Istanbul');
    fakat sitenin saati 10dk ilerde nasıl duzeltebilirim ?
  • 30-08-2012, 22:21:44
    #2
    saati hangi kodla gösteriyorsun ?
  • 31-08-2012, 13:23:27
    #3
    mertdinler adlı üyeden alıntı: mesajı görüntüle
    saati hangi kodla gösteriyorsun ?
    <input type="text" class="span1" name="publish[minute]" id="publish_minute" value="<?php echo date('i', strtotime('+15 minutes')); ?>" maxlength="2">
    cozdum tesekkurler