nowAsString() public static méthode

Example: Clock::freeze('2011-01-02 12:34'); $result = Clock::nowAsString('Y-m-d'); Result: 2011-01-02
public static nowAsString ( string $format = null ) : string
$format string
Résultat string
Exemple #1
0
 /**
  * @test
  */
 public function shouldModifyCurrentDate()
 {
     //when
     $date = Date::modifyNow('2 days');
     //then
     $this->assertGreaterThan(Clock::nowAsString(), $date);
 }
Exemple #2
0
 private function _log($stdOut, $level, $levelName, $message, $params)
 {
     $this->log(function ($message) use($stdOut) {
         $date = Clock::nowAsString();
         $fileHandle = fopen($stdOut, 'a');
         fwrite($fileHandle, "{$date}: {$message}\n");
         fclose($fileHandle);
     }, $level, $levelName, $message, $params);
 }
Exemple #3
0
 /**
  * @test
  */
 public function shouldUseGivenFormat()
 {
     //given
     Clock::freeze('2011-01-02 12:34');
     //when
     $result = Clock::nowAsString('Y-m-d');
     //then
     $this->assertEquals('2011-01-02', $result);
 }
Exemple #4
0
 public function __construct($attributes = [])
 {
     parent::__construct(['attributes' => $attributes, 'fields' => ['id', 'name', 'params', 'created_at' => Clock::nowAsString()]]);
 }
Exemple #5
0
 /**
  * @test
  */
 public function shouldCopyFileContent()
 {
     //given
     StreamStub::register('logfile');
     StreamStub::$body = 'content';
     $tmpFileName = Path::joinWithTemp('test' . Clock::nowAsString('Y_m_d_H_i_s') . '.txt');
     //when
     Files::copyContent('logfile://input', $tmpFileName);
     //then
     $content = file_get_contents($tmpFileName);
     StreamStub::unregister();
     Files::delete($tmpFileName);
     $this->assertEquals('content', $content);
 }
Exemple #6
0
 public function __construct($attributes = [])
 {
     parent::__construct(['attributes' => $attributes, 'fields' => ['id', 'current_game_user_id', 'round' => 1, 'finished' => false, 'winner_game_user_id', 'type', 'started_at' => Clock::nowAsString()], 'belongsTo' => ['current_game_user' => ['class' => 'GameUser', 'foreignKey' => 'current_game_user_id', 'referencedColumn' => 'id'], 'winner_game_user' => ['class' => 'GameUser', 'foreignKey' => 'winner_game_user_id', 'referencedColumn' => 'id']], 'hasMany' => ['game_users' => ['class' => 'GameUser', 'foreignKey' => 'game_id', 'referencedColumn' => 'id']]]);
 }