DD/MM/YYYY Date format in Moment.js

后端 未结 5 1130
北恋
北恋 2021-01-31 07:39

How can i change the current date to this format(DD/MM/YYYY) using moment.js?

I have tried below code.

$scope.SearchDate = moment(new Date(), \"DD/MM/YYY         


        
5条回答
  •  隐瞒了意图╮
    2021-01-31 08:12

    You need to call format() function to get the formatted value

    $scope.SearchDate = moment(new Date()).format("DD/MM/YYYY")
    //or $scope.SearchDate = moment().format("DD/MM/YYYY")
    

    The syntax you have used is used to parse a given string to date object by using the specified formate

提交回复
热议问题