In my usage of ui-calendar, I am attempting to pass events without a specified time. Currently, I am retrieving the date and time in the following manner.
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
var WOD = new Date(y,m,d);
Moreover, I have a function that updates WOD to the selected day in the month view of the calendar like so.
$scope.alertOnDayClick = function(d){
WOD = d;
};
When clicking on a specific day (e.g., Jan 22, 2015), the result is as desired: WOD = "2015-01-22T00:00:00.000Z"
, which works perfectly.
However, in the absence of selecting a day, it defaults to WOD = "2015-01-04T05:00:00.000Z"
.
My aim is to have the default date contain the time T00:00:00.000Z.
Various attempts have been made, including the following:
var WOD = new Date(y,m,d,0,0,0,0)
var WOD = date.UTF(y,m,d)
var WOD = date.UTF(y,m,d,0,0,0,0)
Additionally, setting the default time to null and exploring resources like Dealing with DateTime format for international application has been considered, although the implementation remains unclear.
Any assistance offered would be highly appreciated.
An update on the situation reveals that even after implementing suggestions from What is the best way to initialize a JavaScript Date to midnight?, the issue persists.
For instance, using the code snippet below:
var WOD = new Date();
WOD.setHours(0,0,0,0);
Results in "2015-01-04T05:00:00.000Z"
, consequently affecting the stored event on Jan 4 at 12 am.
Further attempts and refinements have been made, as exemplified in the updated controller below. Despite efforts, the issue remains unresolved.
var myAppModule = angular.module('MyApp', ['ui.calendar']);
myAppModule.controller('MyController', function($scope,$compile,uiCalendarConfig) {
// controller code here
});