0

I'm currently work on a datepicker from angular-ui, I try to save it into firebase, does anyone know how to do that?

I have the following code:

<div class="row">
    <div class="col-md-6">
        <p class="input-group">
          <input type="text" class="form-control" uib-datepicker-popup="{{format}}" ng-model="dt" is-open="popup1.opened" min-date="minDate" max-date="maxDate" datepicker-options="dateOptions" date-disabled="disabled(date, mode)" ng-required="true" close-text="Close" alt-input-formats="altInputFormats" />
          <span class="input-group-btn">
            <button type="button" class="btn btn-default" ng-click="open1()"><i class="glyphicon glyphicon-calendar"></i></button>
          </span>
        </p>
    </div>

and in controller

$scope.dt = new Date();

at pushing the database

dt: dt,

the system shows an error. Does someone know how push the date from datepicker into firebase? Thanks in advance.

Rodolfo Lanshore
  • 97
  • 1
  • 1
  • 11
  • could you share a little bit more code? maybe the whole push would be helpful.. and i guess it's `dt: $scope.dt` (with the "$scope") – nicfo Feb 12 '16 at 14:14
  • Firebase is a JSON database, which means it does not natively support saving of dates. Instead, store the timestamp (milliseconds since the epoch) : see http://stackoverflow.com/questions/30021133/how-do-you-save-a-date-field-in-firebase-using-angularfire – Frank van Puffelen Feb 12 '16 at 14:50
  • And hot about to capture the info in textbox and convert it to string? Is it possible? if it is, how can I make it? – Rodolfo Lanshore Feb 12 '16 at 15:28
  • You mean `dt: dt.toString()`? But keep in mind: once you store a date as a string, it's almost impossible to query against. See http://stackoverflow.com/questions/16382996/firebase-new-date and http://stackoverflow.com/questions/30021133/how-do-you-save-a-date-field-in-firebase-using-angularfire – Frank van Puffelen Feb 13 '16 at 15:18

0 Answers0