简体   繁体   中英

Change date format in PHP to include zeroes

I'm new to PHP. I have a function called jdf and I want to convert Gregorian calendar dates to Jalali but this function returns an array like 2018/7/10 and I need something like 2018/07/10 . Is there anyway to change that format to the one I want?

You can use some already implemented libraries like

https://github.com/roozbeh360/Gregorian-Jalali-Date-Convertor/blob/master/gregorian_jalali.php

and pass year month and date of Gregorian calendar in gregorian_to_jalali function. In response, you will get year month and date of Jalali calendar, which then you can convert to string format as per your requirement .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM