Easyui datetimebox date format into desired format

Source: Internet
Author: User

Because it involves a Easyui datetimebox control to display the date, the date format: h-m-s seconds. such as 18:06:32

To format.

Nonsense not much to say on the code.

  1. <inputclass="Easyui-datetimebox"data-options="Formatter:ww4,parser:w4"style="width:200px;"> yyyy mm month dd Day hh Point </input>

  2. <script type="Text/javascript">

  3. function ww4 (date) {

  4. var  y = date.getfullyear ();

  5. var  m = date.getmonth () +1;

  6. var  d = date.getdate ();

  7. var  h = date.gethours ();

  8. returny+' Year '+ (m<10? (' 0 '+m): m) +' Month '+ (d<10? (' 0 '+d):d) +' Day '+ (h<10? (' 0 '+h): h) +' point ';

  9. }

  10.          function  w4 (s) {   

  11.              var  reg=/[\u4e00-\ u9fa5]/   //uses regular expressions to separate   

  12. var  ss = (S.split (reg));

  13. var  y = parseint (ss[0],10);

  14. var  m = parseint (ss[1],10);

  15. var  d = parseint (ss[2],10);

  16. var  h = parseint (ss[3],10);

  17. if (!isnan (y) &&!isnan (m) &&!isnan (d) &&!isnan (h)) {

  18.                  return new  date (Y,m-1,d,h);   

  19.              } else  {  

  20. return   New Date ();

  21. }

  22. }

  23. </script>

year: date.getfullyear ()
months: month
Days: Day
time: date.gethours ()
points: date.getminutes ()
seconds: data.getseconds ()

Easyui datetimebox date format into desired format

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.