This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# Ipotizziamo che la data di oggi sia il 15/12/2014 | |
echo $this->Customtime->format(date('2014-12-15 15:20:15')); | |
# 'Oggi alle 15:20' | |
echo $this->Customtime->format(date('2014-12-14 15:20:15')); | |
# 'Ieri alle 15:20' | |
echo $this->Customtime->format(date('2014-11-14 15:20:15')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function format($time, $settings = array()) | |
{ | |
$this->setProperties($time, $settings); if ($this->Time->isToday($time)){ | |
return 'Oggi'.$this->settings['hoursMinutes']; | |
} | |
if ($this->Time->wasYesterday($time)){ | |
return 'Ieri'.$this->settings['hoursMinutes']; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
private function setProperties($time, $settings) | |
{ | |
//set a day information | |
$type = (isset($settings['type'])) ? $settings['type'] : 'long'; | |
$this->settings['day'] = $this->Time->format('N', $time); | |
$this->settings['dayLetters'] = $this->days[$this->settings['day']][$type]; | |
$this->settings['dayNumbers'] = $this->Time->format('d', $time); | |
//set a month information |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class CustomtimeHelper extends AppHelper { | |
public $helpers = array('Html', 'Time'); | |
public $days = array( | |
1 => array( | |
'long' => 'Lunedì', | |
'short' => 'Lun' | |
), | |
2 => array( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php echo $this->Customtime->whatDay($data); ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class AppController extends Controller | |
{ | |
public $helpers = array( | |
'Customtime' | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class CustomtimeHelper extends AppHelper { | |
public $helpers = array('Time'); | |
public $days = array( | |
1 => 'Lunedì' | |
2 => 'Martedì' | |
3 => 'Mercoledì' | |
4 => 'Giovedì' | |
5 => 'Venerdì' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class CustomtimeHelper extends AppHelper { | |
$days = array( | |
1 => 'Lunedì' | |
2 => 'Martedì' | |
3 => 'Mercoledì' | |
4 => 'Giovedì' | |
5 => 'Venerdì' | |
6 => 'Sabato' | |
7 => 'Domenica' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
#/app/Model/Book.php | |
class Book extends AppModel { | |
public $name = 'Book'; | |
public $displayField ='title'; | |
public $belongsTo = array('Author'); | |
public $validate = array( | |
'title' => array( | |
'rule' => array('notEmpty'), | |
'required' => true, |