1

I have created an application in angularjs in which i have added a javascript date for the date 21/10/2014 07:30AM, To make it into date object i did like as shown below

 new Date(2014, 10, 21, 07, 30);

but interestingly when i print it out i got like

2014-11-21T13:30:00.000Z

My code is as given below

JSFiddle

var app = angular.module('myApp', []);
app.controller('Controller', function ($scope) {
    $scope.myValues = {};
    $scope.myValues.start = new Date(2014, 10, 21, 07, 30);
});

Can anyone please tell me why the time is different, also how can i correct that since i am saving this in database through php, Also many areas i need to get only the time

Alex Man
  • 4,746
  • 17
  • 93
  • 178

1 Answers1

2

In this case you can do some custom formatting

separate year,month day hour .. and rearrange them to create a sql datetime compatible string

here is the working Fiddle

Kalhan.Toress
  • 21,683
  • 8
  • 68
  • 92