Convert date into word format

后端 未结 5 1673
醉话见心
醉话见心 2021-01-28 05:42

I\'m not sure how i will do it, I want convert date in english word format, like this if date is 10-10-1988 then

In English- tenth October nineteen eighty eight
         


        
5条回答
  •  耶瑟儿~
    2021-01-28 06:28

    With credits to an article on About.com, I figured out a perfect solution to this question.

    The above reference helped me parse the Numerals in date to Words, while I tweaked it a little for helping me with Months.

    var stu = $("#txtStartDate").val().split('-');
    var wMonths=['january','february','march','april','may','june','july','august','september','october','november','december']
    var final  = toWords(stu[0]) + " " + wMonths[parseInt(stu[1])-1] + " " + toWords(stu[2])   
    alert(final);
    
    function toWords(s)
    {
        // Open Fiddle for complete code
        // convert number to words
    }
    

    Follow this Fiddle for the complete code. Hope this helps someone.

提交回复
热议问题