public static function toJalali() { $date = new jDateTime(true, true, 'Asia/Tehran'); $d = date('Y-m-d', strtotime('-7 day')); $exp = explode('-', $d); $result = $date->toJalali($exp[0], $exp[1], $exp[2]); if ($result[1] <= 9) { $_d = '0' . $result[1]; } else { $_d = $result[1]; } if ($result[2] <= 9) { $_m = '0' . $result[2]; } else { $_m = $result[2]; } return $result[0] . '-' . $_d . '-' . $_m; }
/** * Converts Gregorian DateTime to Jalali and return it as string. * By Ahmad Pouramini */ public static function toJalaliStr($g_date, $curSep = '-', $newSep = '/') { $arr = explode($curSep, $g_date); if (count($arr) < 3 || intval($arr[2]) == 0) { //invalid dates return ""; } else { $j_date = jDateTime::toJalali($arr[0], $arr[1], $arr[2]); } $j_date_rev = array($j_date[2], $j_date[1], $j_date[0]); return implode($newSep, $j_date_rev); }