M Majid DS mds
GitHub

mds components

mds:jalali-date

Jalali (Shamsi) dates, with no external calendar dependency.

The conversion is implemented in the package itself — no ext-intl, no calendar library. The calendar is always Jalali; the output language follows config('mds.persian_digits'), so on these pages you get Latin digits and transliterated names.

<mds:jalali-date :date="now()" format="l j F Y" />

Formats

Same format characters as PHP's date(). Month and weekday names follow the output language: transliterations like Shahrivar and English weekdays here, فروردین تا اسفند and Persian weekdays in Persian.

<div class="space-y-1 text-sm">
    <div><mds:jalali-date :date="now()" format="l j F Y" /></div>
    <div><mds:jalali-date :date="now()" format="j F Y" /></div>
    <div><mds:jalali-date :date="now()" format="Y/m/d" /></div>
</div>

Relative

ago gives a short relative phrase — "3 hours ago", "in 2 days", "just now" — with the full date in the title.

<div class="space-y-1 text-sm">
    <div><mds:jalali-date :date="now()->subHours(3)" ago /></div>
    <div><mds:jalali-date :date="now()->subDays(4)" ago /></div>
</div>

Blade directive

The directive reads the config too, so on these pages it comes out transliterated.

Registered on 2 Shahrivar 1405.

<flux:text>Registered on @jalali(now()).</flux:text>

Persian output

config('mds.persian_digits') — on by default in a real app, off in these docs — switches the whole output to Persian: digits, month and weekday names, and the relative phrases; :fa="true" does it for a single date.

<div class="space-y-1 text-sm">
    <div><mds:jalali-date :date="now()" format="l j F Y" :fa="true" /></div>
    <div><mds:jalali-date :date="now()->subDays(4)" ago :fa="true" /></div>
</div>

Reference

mds:jalali-date

PropDescription
dateA Carbon instance, a timestamp or a parseable string.
formatPHP date format characters. Default: j F Y.
agoRenders a relative phrase instead. Default: false.
faPersian output — digits, names and relative phrases; Latin digits with transliterated names when off. Default: config('mds.persian_digits').

@jalali

Blade directive: @jalali($date, $format = 'j F Y'). Follows the config for digits and names.

MajidDs\Support\Jalali

The PHP helper behind the component: Jalali::format(), Jalali::fromGregorian(), Jalali::toGregorian().

Related