I need to set today date is server date but in fullCalendar it is displaying local system date as today date.
I have set server date with gotoDate option as following.
$('#calendar').fullCalendar('gotoDate', currentDate);
but it is not working properly as i click on the today button it is displaying local system date.
please help me.
You can set the default date in fullcalendar:
https://fullcalendar.io/docs/current_date/defaultDate/
you have to use moment plugin (which is a third party plugin and you have to include it separately in your project before fullcalendar)
https://fullcalendar.io/docs/utilities/Moment/
I set the current date on click of today button. Code is as following.
$('.fc-today-button').click(function () {
$('#calendar').fullCalendar('gotoDate', currentDate);
});
Related
Ngx Bootstrap Datepicker returns a JS Date object.
I have a custom Time picker that returns a string formatted as HH:mm.
What I need to do right now is to create a JS Date object with the selected Date, selected Time and a specific TimeZone.
I'm trying to use moment (cause we use that for dates in the whole application) but I'm having not expected behaviours.
I'm trying to:
const specificMoment = moment.tz(date, timeZone); // date is the Ngx Bootstrap selected date
specificMoment.set('hour', +time.split(':')[0]); // time is HH:mm string
specificMoment.set('minute', +time.split(':')[1]);
return specificMoment.toDate
*timeZone changes according to the user, not due to it's browser, it's an attribute of the user, so I can't set moment.tz.setDefault(...);.
What I'm facing is that .toDate is returning my current timeZone, event though it appears my different timeZone inside the moment object.
Why is it working like this and what would be a working implementation for what I need?
Ps: console.log(specificMoment.format()); returns wrong timeZone as well 2018-12-20T23:00:30-02:00.
EDIT
Turns out using const specificMoment = moment(date).tz(timeZone); and then return specificMoment.toDate() "works". It returns a Date object with 2018-12-21T05:00:00.323-0200, which is the date with specified timezone (GMT -8:00) but displayed on my current timezone (GMT -2:00).
The data is stored on my DB correctly.
Can someone explain why?
Thx.
It looks like you haven't setup moment-timezone with any data about the timezone to use.
Check out this link on Data Loading in momentjs.
I've created a JS Bin for your example that shows how to use Data Loading. Check it out here.
e.g.
moment.tz.add([
'America/Los_Angeles|PST PDT|80 70|0101|1Lzm0 1zb0 Op0',
'America/New_York|EST EDT|50 40|0101|1Lz50 1zb0 Op0'
]);
Hi I am developing web application in angularjs. I am developing one form and i have one textbox with date picker. I am using 720kb date picket pluggin. https://github.com/720kb/angular-datepicker I want users to allow dates after 1 month. For example if today is august 14 then i want to enable dates only after september 14. I have added moment.js and put
var date = moment();
date.add(1, 'months');
console.log(date);
$scope.maxdate=date.d;
In html i have date-min-limit="maxdate". How ever this is not going to work. I got date-max-limit="" method from the above mentioned document. May i know what i am doing wring in the above code? Can someone help me to fix this? Thank you.
date-min-limit="" expects a string version of short date
In your controller
$scope.maxdate = moment().add(1, 'M').format('MM/DD/YYYY');
In your html
date-min-limit="maxdate"
If you use bootstrap, you can use this pluggin https://github.com/uxsolutions/bootstrap-datepicker
In its example,demos, you can set start date.
I've a field and applying datepicker on it using jQuery.
it is currently getting time from system/browser.
I want it to get time from specific time zone e.g America/new_york.
The endDate param is the key to set the calendar, means user should not be able to select the date from future. Currently it is looking like this
The code snippet is :
jQuery('#convo_start_date').datepicker({
format: 'dd M yyyy',
endDate: '+0d',
autoclose: true,
showButtonPanel: true,
todayBtn: 'linked'
}).on('change', function () {
jQuery('.datepicker').hide();
jQuery('#convo_end_date').attr('value',jQuery('#convo_start_date').val());
});
Question: Is there any way to set the default specific timezone like America/new_york to do not allow the date from future (according to this specific timezone)?
Note: I've tried moment.js but it is conflicting with my current work in jQuery, Is there any params datepicker library providesvto set with timezone?
If you are using jquery ui datepicker plugin, you can set the maxDate option to current date so that user can't select date from future.
You will need to do the conversion to the specific timezone. You can change the targetTimeOffset variable as per your requirement.
var d = new Date();
var targetTimeOffset = -4*60; //desired time zone, taken as GMT-4
d.setMinutes(d.getMinutes() + d.getTimezoneOffset() + targetTimeOffset );
Check Fiddle: http://jsfiddle.net/mpsingh2003/8w8v9/3387/ if this is what you are looking for
You can use Joda-Time library to get your solution.
Check the classes they provide like org.joda.time.DateTimeZone.
You can get the DateTimeZone depending on the Canonical ID defined in the Joda Time.
Please check this link for API documentation.
Hope this will helpful for you. Thanks.
I am using Bootstrap datepicker and on selecting different values from a list its startdate is changing. It is working fine if I set the startdate 2013 from 2008 but it doesn't work if a select start date 2008 and currently its 2013.
What could be the reason here?
$('#datepicker').datepicker('setStartDate', updatedDate);
This line I am executing whenever I select different startDate.
Really need to know what updatedDate value is.
However, if you read the docs for the dtepicker the value passed in must be a string that is understandable by format
https://bootstrap-datepicker.readthedocs.io/en/latest/methods.html#setstartdate
https://bootstrap-datepicker.readthedocs.io/en/latest/options.html#startdate
Date or String. Default: Beginning of time
The earliest date that may be selected; all earlier dates will be
disabled.
Date should be in local timezone. String must be parsable with format.
So what you pass in as the format option must match the format of your start date. If you do not set the format optin, the default is "mm/dd/yyyy"
Without seeing code, I can only hypothesize; try calling [...].datepicker('update', 'date_string'); on the object to force an update on the control.
I am using fuelux date picker and I have two date pickers on a page. Basically a start date and an end date. What I want to do is initialize both at the beginning and then when the user select a start date then restrict the end date picker to only have date starting from the start date that was selected by the user.
// Initialize datepickers
$('#startDate, #endDate').datepicker();
// When the start date changed by user
$('#startDate').on('changed.fu.datepicker dateClicked.fu.datepicker', function (evt, startDate) {
$('#endDate').datepicker('setDate', startDate);
$('#endDate').datepicker({
restricted: [{ from: '01/01/1900', to: startDate }]
});
});
Right now the set date works but restricted doesn't. Any solution?
You are trying to re-initialize the end date with different options which Fuel UX doesn't support. For your idea to work, you cannot initialize the end date until the start date is set.
Please review Destruction and re-initialization