StandardDate.class.php (912B)
1 <?php 2 namespace dsl\standard; 3 4 use dsl\context\BaseScriptableObject; 5 6 class StandardDate extends BaseScriptableObject 7 { 8 /** 9 * Date.now() 10 * 11 * milliseconds since 1970. 12 * 13 * @return int 14 */ 15 public function now() { 16 17 return time(); 18 } 19 20 21 22 /** 23 * Gets the current date object. 24 * @return Date 25 */ 26 public function getDate( $date = null ) { 27 28 return new Date( $date ); 29 } 30 31 32 33 /** 34 * Gets the current date object for a given date. 35 * @return Date 36 */ 37 public function getDateFor( $year = 0,$month = 0,$day = 0,$hour = 0,$minute = 0,$second = 0 ) { 38 39 $month++; // month in JS is 0-based, but in PHP not. 40 41 return new Date( mktime( $hour, $minute, $second, $month, $day, $year ) ); 42 } 43 44 45 public function __toString() 46 { 47 return "Arrays:Object"; 48 } 49 50 public function help() 51 { 52 return Helper::getHelp($this); 53 } 54 55 56 public function parse( $dateAsString ) { 57 58 return strtotime( $dateAsString ); 59 } 60 }