Skip to content

Instantly share code, notes, and snippets.

@relyky
Last active December 29, 2016 10:17
Show Gist options
  • Save relyky/8f462e6c3a7ac997be78 to your computer and use it in GitHub Desktop.
Save relyky/8f462e6c3a7ac997be78 to your computer and use it in GitHub Desktop.
Angular JS - dateFormat
# 可引用 $filter 處理
# ref → https://docs.angularjs.org/api/ng/filter/date
// 日期格式處理
$scope.checkTimeFmt = $filter('date')($scope.checkTime, 'yyyy/MM/dd HH:mm:ss');
// 等同在html
{{checkTime | date:'yyyy/MM/dd HH:mm:ss' }}
//-------------------
# 日期格式轉換
$scope.ASSIGN_DT = new Date($scope.ASSIGN_DT).dateFormat("Y/m/d");
# 格式 年/月/日 時:分
new Date().dateFormat("Y/m/d h:i"), // yyyy/MM/dd HH:mm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment