talal424 / calendars

Support for various world calendars including Islamic calendar (UmmAlQura)
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Convert from Gregorian To UmmAlQura #1

Closed ShadyIbrahim closed 6 years ago

ShadyIbrahim commented 6 years ago

Please How Can i convert from Gregorian Like 21/05/2018 and return 06/09/1439

i tried $Gregorian = Calendars::calendar('Gregorian'); $date = $Gregorian->newDate(2018,5,21); $date = $Gregorian->fromJD($date);

but get Error

talal424 commented 6 years ago

you got it wrong $date = $Gregorian->fromJD($date); here the date is already from Gregorian date

this is how to convert Gregorian

`` use Talal424\Calendars\Calendars; require 'vendor/autoload.php'; $Gregorian = Calendars::calendar('Gregorian'); $UmmAlQura = Calendars::calendar('UmmAlQura');

$newGregorianDate = $Gregorian->newDate(2018,5,21);

$gregorianDateToJd = $newGregorianDate->toJD();

// or $gregorianDateToJd = $Gregorian->toJD(2018,5,21);

$newUmmAlQuraDate = $UmmAlQura->fromJD($gregorianDateToJd);

echo $UmmAlQura->formatDate('yyyy/mm/dd E',$newUmmAlQuraDate,['localNumbers'=>false]);