Home  >  Q&A  >  body text

javascript - js regular replacement date format problem

'2017-6-5'.replace(/-(\d{1})$|-/g,'0'),返回为什么是20170605,少了"-",我要的结果是2017-06-05
阿神阿神2663 days ago893

reply all(1)I'll reply

  • 为情所困

    为情所困2017-07-05 11:07:19

    '2017-6-5'.replace(/-(d{1})/g,'-0$1') Try writing it like this.

    reply
    0
  • Cancelreply