1. Go to this page and download the library: Download picobaz/jalaliflow library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use PicoBaz\JalaliFlow\Facades\JalaliFlow;
// Assuming today is 1404/02/24 (2025-05-22)
echo JalaliFlow::toRelativeJalali('2025-05-22'); // Output: امروز
echo JalaliFlow::toRelativeJalali('2025-05-21'); // Output: دیروز
echo JalaliFlow::toRelativeJalali('2025-05-24'); // Output: ۲ روز بعد
echo JalaliFlow::toRelativeJalali('2025-05-19'); // Output: ۳ روز پیش
echo JalaliFlow::toRelativeJalali('2025-05-19', 'Asia/Tehran', 'en'); // Output: 3 days ago
use PicoBaz\JalaliFlow\Facades\JalaliFlow;
$holidays = JalaliFlow::getHolidays(1404);
foreach ($holidays as $date => $description) {
echo "$date: $description\n";
}
// Example output:
// 1404/01/01: نوروز
// 1404/01/02: نوروز
// 1404/01/03: نوروز
// 1404/01/04: نوروز
// 1404/01/13: روز طبیعت
// 1404/12/29: روز ملی شدن صنعت نفت
use PicoBaz\JalaliFlow\Facades\JalaliFlow;
try {
$date = '1404/01/01';
echo JalaliFlow::isHoliday($date) ? "$date is a holiday" : "$date is not a holiday";
// Output: 1404/01/01 is a holiday
$date = '1404/02/24';
echo JalaliFlow::isHoliday($date) ? "$date is a holiday" : "$date is not a holiday";
// Output: 1404/02/24 is not a holiday
} catch (Exception $e) {
echo "Error: " . $e->getMessage();
}
use PicoBaz\JalaliFlow\Facades\JalaliFlow;
try {
$date = '1404/02/24';
echo JalaliFlow::isWorkingDay($date) ? "$date is a working day" : "$date is not a working day";
// Output: 1404/02/24 is a working day (assuming it's not a Friday)
$date = '1404/01/01';
echo JalaliFlow::isWorkingDay($date) ? "$date is a working day" : "$date is not a working day";
// Output: 1404/01/01 is not a working day (Nowruz holiday)
} catch (Exception $e) {
echo "Error: " . $e->getMessage();
}
use PicoBaz\JalaliFlow\Facades\JalaliFlow;
use Illuminate\Support\Facades\DB;
// Example: Add a daily record to the database
JalaliFlow::createEvent(
name: 'Add Daily Record',
frequency: 'daily',
startDate: '1404/02/24',
action: function () {
DB::table('records')->insert(['created_at' => now()]);
}
);
// Example: Call a class method monthly
JalaliFlow::createEvent(
name: 'Monthly Report',
frequency: 'monthly',
startDate: '1404/02/24',
action: 'App\Services\ReportService@generateMonthly'
);
use PicoBaz\JalaliFlow\Facades\JalaliFlow;
try {
$date = '1404/04/25'; // Approximate date for Ashura 1446
echo JalaliFlow::isIslamicHoliday($date, 'jalali') ? "$date is an Islamic holiday" : "$date is not an Islamic holiday";
// Output: 1404/04/25 is an Islamic holiday (if Ashura)
$date = '1404/02/24';
echo JalaliFlow::isIslamicHoliday($date, 'jalali') ? "$date is an Islamic holiday" : "$date is not an Islamic holiday";
// Output: 1404/02/24 is not an Islamic holiday
} catch (Exception $e) {
echo "Error: " . $e->getMessage();
}
use PicoBaz\JalaliFlow\Facades\JalaliFlow;
try {
$days = JalaliFlow::workingDaysBetween('1404/02/20', '1404/02/27');
echo "Working days: $days";
// Output: Working days: 5 (assuming no holidays, excluding Friday)
$days = JalaliFlow::workingDaysBetween('1404/01/01', '1404/01/07');
echo "Working days: $days";
// Output: Working days: 2 (excluding Nowruz holidays and Friday)
$days = JalaliFlow::workingDaysBetween('1404/02/24', '1404/02/24');
echo "Working days: $days";
// Output: Working days: 0 (same start and end date)
} catch (Exception $e) {
echo "Error: " . $e->getMessage();
}