ZulNs / Datepicker.js

JavaScript library to creates Hijri/Gregorian Datepicker
MIT License
20 stars 7 forks source link

how to get the date value like 16/03/2019 #2

Closed tayeh closed 5 years ago

tayeh commented 5 years ago

hi can i get the date in format 16/03/2019 also i need it for hijri date ?

tayeh commented 5 years ago

plus i need to reconvert the date to string :)

ZulNs commented 5 years ago

@Tayeh, Assume Datepicker object is picker Then picker.getPickedDate() will return Date or HijriDate object depend on Datepicker dates mode. To extract the date in format DD/MM/YYYY you can use following code snippet:

let date = picker.getPickedDate();
let formattedDate = HijriDate.toNDigit(date.getDate(), 2) + '/' + HijriDate.toNDigit(date.getMonth()+1, 2) + '/' + HijriDate.toNDigit(date.getFullYear(), 4);