Reputation: 433
Im using ionicframework to build hybrid app with angular.
im having a form with two input box : date and time. The value of date input is saved in the database as:
Tue Mar 24 2015 00:00:00 GMT 0300 (AST)
i get this type of data when running the form on my android device, but i want to save the date as simple like: 24-04-2015
What i tried
form.html
<form>
<input ng-model="app.date" class="positive" type="date">
<input ng-model="app.time" class="positive" type="time">
<button ng-click="makeApp(app)">send</button>
</form>
controller.js
$scope.makeApp = function (app) {
$http.post("http://www.foo.com/senddata.php?date="+app.date+"&time="+app.time)
.success(function(data){
});
Upvotes: 1
Views: 14057
Reputation: 13997
You can use Angular's date filter:
myApp.controller('MyController', ['$scope', '$http', '$filter', function ($scope, $http, $filter) {
$scope.makeApp = function (app) {
var appDate = $filter('date')(app.date, "dd/MM/yyyy");
$http.post("http://www.foo.com/senddata.php?date="+appDate+"&time="+app.time)
.success(function(data){
// success
});
}
}
https://docs.angularjs.org/api/ng/filter/date
Upvotes: 5