Closed ks465 closed 5 years ago
The complete methods are:
* @version 3.3.1-980217
/**
* Convert a typical date string into timestamp
*
* @param string $dateString
*
* @return int
*/
public static function getTimestampFromString($dateString)
{
if(empty($dateString)){
return null;
}
$rx = '~^(\d{2,4})\D(\d{1,2})\D(\d{1,2})$~';
preg_match($rx, $dateString, $segments);;
return Jalali::mktime($segments[1], $segments[2], $segments[3]);
}
/**
* Rewrites a date string in standardize format based on the given format
*
* @param string $dateString typical date string
* @param string $format the output format. Defaults to [Jalali::KHAN_SHORT]
*
* @return mixed
*/
public static function standardize($dateString, $format = Jalali::KHAN_SHORT)
{
if(empty($dateString)){
return null;
}
return Jalali::date($format, time($dateString));
}
Done
Add a method to create timestamp from date string, and one to return the date string in standardize format: