Stack Exchange
how to pass the date into the firebase in YYMMDD format?
I have created a album functionality in the angularJS 


$scope.createAlbumDialog = function(event, productObj) {
    //HERE WE WILL SET THE userCategoryKeyId FROM THE productObj
    $scope.selectedCategoryKey  =  productObj.userCategoryKeyId;
    $scope.albumName            =  $scope.user.userSearchInProduct;

    //HERE WE WILL CREATE FB REF. AND CHECK ALBUM ALREADY EXIST OR NOT
    if($scope.selectedProductKey.length > 0) {
      var PRODUCT_DB_REF = firebase.database().ref('datastore/productsAlbum');
     
      //HERE WE WILL PASS THE KEYID INTO THE FIREBASE NODE'S 
      PRODUCT_DB_REF.child($scope.selectedCategoryKey).child(AUTH.userTypeKeyId).
      orderByChild("albumNameLC").equalTo($scope.albumName.toLowerCase()).once('value').then(function (snapshot) {
         var value = snapshot.val();
          if (value) {
            //SHOW ALERT IF PRODUCT IS ALREADY EXIST IN THE ALBUM
            CMN.showNotification("bottom","right","info", "Album is already exist");

          } else {
            //HERE WE WILL GET THE TIME DURING PUSH THE DATA INTO THE FIREBASE....
            var date = new Date().getTime();

            PRODUCT_DB_REF.child($scope.selectedCategoryKey).child(AUTH.userTypeKeyId).push({
              albumName             : $scope.albumName,
              albumNameLC           : $scope.albumName.toLowerCase(),
              sellerUserTypeKeyId   : Number(AUTH.userTypeKeyId),
              productKey            : $scope.selectedProductKey,
              createDate            : Number(date)
            });
            //SHOW ALERT AFTER CREATED THE ALBUM
            CMN.showNotification("bottom","right","success", "Album is successfully created");
          };
        }
      )
     //HERE WE WILL BLANK THE INPUT FIELD AFTER CLICK ON THE BUTTON
     $scope.user.userSearchInProduct = "";
  } else {
      //SHOW ALERT IF PRODUCT IS NOT FOUND
     swal('<span style="color:red"><h4>Select atleast 1 product for create the album</h4><span>'); 
     }
   }



and i have to pass the createDate into firebse and i am using  new Date().getTime() and my date format is - 1509167255906 but i have to the pass into firebase into the YYMMDD format how to do this?

You can do like below
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
   if(dd<10)
      dd='0'+dd;
   if(mm<10)
      mm='0'+mm;

   var formatedDate= yyyy +'/'+mm+'/'+dd; or var formatedDate= yyyy +'-'+mm+'-'+dd; 
   //pass the formatedDate into firebase push

  PRODUCT_DB_REF.child($scope.selectedCategoryKey).child(AUTH.userTypeKeyId).push({
          albumName             : $scope.albumName,
          albumNameLC           : $scope.albumName.toLowerCase(),
          sellerUserTypeKeyId   : Number(AUTH.userTypeKeyId),
          productKey            : $scope.selectedProductKey,
          createDate            : formatedDate,
        });

See this for sample 

thank you sir Its working for me . this is my format now ..createDate:
"2017/10/28".sir can you tell me how it is working internally?

Happy to help. Please accept the answer if i delivered what you need
