Nepali Date Converter with JS

<html lang="en">
    <head>
        <title>Nepali Datepicker v3.7</title>
        <meta http-equiv="x-ua-compatible" content="ie=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <meta charset="utf-8" />
        <!-- Nepali Datepicker -->
       <link href="https://nirajang.com.np/wp-content/uploads/2022/06/nepali.datepicker.min_.css" rel="stylesheet" type="text/css"/>
    </head>
    <body>
        <p>
           <input type="text" id="nepali-datepicker" class="nepali-datepicker"><button onclick="myFunction()">Try it</button>
           <input type="text" id="convert-date">
        </p>
 
        <script src="https://nirajang.com.np/wp-content/uploads/2022/06/nepali.datepicker.v3.7.min_.js" type="text/javascript"></script>
        <script type="text/javascript">

            var currentDate = NepaliFunctions.ConvertDateFormat(NepaliFunctions.GetCurrentBsDate(), "YYYY-MM-DD");
        document.getElementById("nepali-datepicker").value = currentDate;
        var mainInput = document.getElementById("nepali-datepicker");
            mainInput.nepaliDatePicker({
    language: "english",
    readOnlyInput: true,
        });
        
function myFunction() {
  var innepali = document.getElementById("nepali-datepicker").value;
 // document.getElementById("demo").value = x;

           var dateobj = NepaliFunctions.ConvertToDateObject(innepali, "YYYY-MM-DD");
           var convertdate = NepaliFunctions.ConvertDateFormat(NepaliFunctions.BS2AD(dateobj), "YYYY-MM-DD");

        document.getElementById("convert-date").value = convertdate;
        	
}
        
        </script>
        
    </body>
    
</html>

Leave a Reply

Your email address will not be published.