Created
December 17, 2016 09:17
-
-
Save hasibkamal/d27a04b027e5f84b43232b348e4906ee to your computer and use it in GitHub Desktop.
Study with DATE
This file contains hidden or 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
1> | |
if($request->get('carrier_pass_validity') != '') | |
$exportPermit->carrier_pass_validity = CommonFunction::changeDateFormat($request->get('carrier_pass_validity'),true); | |
2> | |
class CommonFunction { | |
public static function changeDateFormat($dateicker, $mysql = false) { | |
if ($mysql) { | |
return Carbon::createFromFormat('d-M-Y', $dateicker)->format('Y-m-d'); | |
} else { | |
return Carbon::createFromFormat('Y-m-d', $dateicker)->format('d-M-Y'); | |
} | |
} | |
} | |
3> | |
class Carbon extends DateTime{ | |
public static function createFromFormat($format, $time, $tz = null) | |
{ | |
if ($tz !== null) { | |
$dt = parent::createFromFormat($format, $time, static::safeCreateDateTimeZone($tz)); | |
} else { | |
$dt = parent::createFromFormat($format, $time); | |
} | |
if ($dt instanceof DateTime) { | |
return static::instance($dt); | |
} | |
$errors = static::getLastErrors(); | |
throw new InvalidArgumentException(implode(PHP_EOL, $errors['errors'])); | |
} | |
} | |
4> | |
class DateTime implements DateTimeInterface { | |
const ATOM = 'Y-m-d\TH:i:sP'; | |
const COOKIE = 'l, d-M-y H:i:s T'; | |
const ISO8601 = 'Y-m-d\TH:i:sO'; | |
const RFC822 = 'D, d M y H:i:s O'; | |
const RFC850 = 'l, d-M-y H:i:s T'; | |
const RFC1036 = 'D, d M y H:i:s O'; | |
const RFC1123 = 'D, d M Y H:i:s O'; | |
const RFC2822 = 'D, d M Y H:i:s O'; | |
const RFC3339 = 'Y-m-d\TH:i:sP'; | |
const RSS = 'D, d M Y H:i:s O'; | |
const W3C = 'Y-m-d\TH:i:sP'; | |
/** | |
* @param string $time | |
* @param DateTimeZone $timezone | |
* @return DateTime | |
* @link http://php.net/manual/en/datetime.construct.php | |
*/ | |
public function __construct ($time='now', DateTimeZone $timezone=null) {} | |
/** | |
* @return DateTime | |
* @link http://php.net/manual/en/datetime.wakeup.php | |
*/ | |
public function __wakeup () {} | |
/** | |
* Returns date formatted according to given format. | |
* @param string $format | |
* @return string | |
* @link http://php.net/manual/en/datetime.format.php | |
*/ | |
public function format ($format) {} | |
/** | |
* Alter the timestamp of a DateTime object by incrementing or decrementing | |
* in a format accepted by strtotime(). | |
* @param string $modify A date/time string. Valid formats are explained in <a href="http://www.php.net/manual/en/datetime.formats.php">Date and Time Formats</a>. | |
* @return DateTime Returns the DateTime object for method chaining or FALSE on failure. | |
* @link http://php.net/manual/en/datetime.modify.php | |
*/ | |
public function modify ($modify) {} | |
/** | |
* Adds an amount of days, months, years, hours, minutes and seconds to a DateTime object | |
* @param DateInterval $interval | |
* @return DateTime | |
* @link http://php.net/manual/en/datetime.add.php | |
*/ | |
public function add (DateInterval $interval) {} | |
/** | |
* Subtracts an amount of days, months, years, hours, minutes and seconds from a DateTime object | |
* @param DateInterval $interval | |
* @return DateTime | |
* @link http://php.net/manual/en/datetime.sub.php | |
*/ | |
public function sub (DateInterval $interval) {} | |
/** | |
* Get the TimeZone associated with the DateTime | |
* @return DateTimeZone | |
* @link http://php.net/manual/en/datetime.gettimezone.php | |
*/ | |
public function getTimezone () {} | |
/** | |
* Set the TimeZone associated with the DateTime | |
* @param DateTimeZone $timezone | |
* @return DateTime | |
* @link http://php.net/manual/en/datetime.settimezone.php | |
*/ | |
public function setTimezone ($timezone) {} | |
/** | |
* Returns the timezone offset | |
* @return int | |
* @link http://php.net/manual/en/datetime.getoffset.php | |
*/ | |
public function getOffset () {} | |
/** | |
* Sets the current time of the DateTime object to a different time. | |
* @param int $hour | |
* @param int $minute | |
* @param int $second | |
* @return DateTime | |
* @link http://php.net/manual/en/datetime.settime.php | |
*/ | |
public function setTime ($hour, $minute, $second=0) {} | |
/** | |
* Sets the current date of the DateTime object to a different date. | |
* @param int $year | |
* @param int $month | |
* @param int $day | |
* @return DateTime | |
* @link http://php.net/manual/en/datetime.setdate.php | |
*/ | |
public function setDate ($year, $month, $day) {} | |
/** | |
* Set a date according to the ISO 8601 standard - using weeks and day offsets rather than specific dates. | |
* @param int $year | |
* @param int $week | |
* @param int $day | |
* @return DateTime | |
* @link http://php.net/manual/en/datetime.setisodate.php | |
*/ | |
public function setISODate ($year, $week, $day=1) {} | |
/** | |
* Sets the date and time based on a Unix timestamp. | |
* @param int $unixtimestamp | |
* @return DateTime | |
* @link http://php.net/manual/en/datetime.settimestamp.php | |
*/ | |
public function setTimestamp ($unixtimestamp) {} | |
/** | |
* Gets the Unix timestamp. | |
* @return int | |
* @link http://php.net/manual/en/datetime.gettimestamp.php | |
*/ | |
public function getTimestamp () {} | |
/** | |
* Returns the difference between two DateTime objects represented as a DateInterval. | |
* @param DateTime $datetime2 The date to compare to. | |
* @param boolean $absolute [optional] Whether to return absolute difference. | |
* @return DateInterval|boolean The DateInterval object representing the difference between the two dates or FALSE on failure. | |
* @link http://php.net/manual/en/datetime.diff.php | |
*/ | |
public function diff ($datetime2, $absolute = false) {} | |
/** | |
* Parse a string into a new DateTime object according to the specified format | |
* @param string $format Format accepted by date(). | |
* @param string $time String representing the time. | |
* @param DateTimeZone $timezone A DateTimeZone object representing the desired time zone. | |
* @return DateTime | |
* @link http://php.net/manual/en/datetime.createfromformat.php | |
*/ | |
public static function createFromFormat ($format, $time, DateTimeZone $timezone=null) {} | |
/** | |
* Returns an array of warnings and errors found while parsing a date/time string | |
* @return array | |
* @link http://php.net/manual/en/datetime.getlasterrors.php | |
*/ | |
public static function getLastErrors () {} | |
/** | |
* @param array $array | |
* @link http://php.net/manual/en/datetime.set-state.php | |
*/ | |
public static function __set_state ($array) {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment