I've seen answers that use either, new Date() or moment() to declare minDate and been marked as the answer but in my case neither worked.
E.g. How to disable past dates from today in bootstrap datetimepicker?
The code is:
$('.datePicker').datetimepicker({
//format: "HH:ii P, dd M yyyy",
//format: 'YYYY-MM-DD',
//minDate: new Date(),
//minDate: moment(),
minuteStep: 1,
showMeridian: true,
todayBtn: true
});
Bootstrap v3.3.7 is being used and it looks like:
As you can see the dates prior to the 16th (today) aren't being disabled. Could this be due to my bootstrap version?
minDate is for eonasdan-datetimepicker, while tarruda's datetimepicker uses startDate:
Options
These are the default options for initializing the widget:
$.fn.datetimepicker.defaults = {
startDate: -Infinity, // set a minimum date
endDate: Infinity // set a maximum date
};
Related
I have a field that shows the current date and next to that is a counter where you can add one month to the current date. This was as intended, because I always want the current date to be the default one. But I would also like to allow my users to pick a different date and then count the months from that selected date. They can't do this right now. if they select a date and add one month, the date will automatically update to be todays date + 1 month.
How can I change this so that the default date is still the current date, while allowing users to select a different date and add one month to THAT date.
Eg. if today is 15/11/2022 and the user picks the 17th and adds one month, I would like the date to change to to 17/12/2022. Right now it will only change to 15/12/2022 even if the user enters the 17th.
<template>
<date-picker v-model="startDate" format="DD/MM/YYYY"/>
<b-form-spinbutton v-model="counter" min="0"/>
</template>
<script>
export default {
data() {
return {
counter: 0,
startDate: moment(new Date()).format('YYYY-MM-DD')
}
},
methods: {
populateDateAccordingly() {
this.startDate = moment().format('YYYY-MM-DD');
this.startDate = moment().add(this.counter, 'M').format('YYYY-MM-DD');
}
},
watch: {
counter : 'populateDateAccordingly'
},
}
}
</script>
I am writing a script in python to create an event.Newbie at this.Below is the entire script code for reference.
import requests,json
from datetime import datetime
event={}
event['name']={}
print("Enter the following:\ntitle of event")
event['name']['html']=input()
event['description']={}
event['description']['html']=input("Event description:\n")
event['start']={}
startdate=datetime.strptime(input("start datetime eg :Jun 1 2005 1:33PM :\n"),'%b %d %Y %I:%M%p')
event['start']['utc']=str(startdate.date())+'T'+str(startdate.time())+'Z'
#event['start']['utc']=startdate.isoformat()+"Z"
#Turning datetime in YYYY-MM-DDThh:mm:ssZ format
event['start']['timezone']=input("timezone eg Asia/kolkata\n")
event['end']={}
enddate=datetime.strptime(input("end datetime eg :Jun 1 2005 1:33PM\n"),'%b %d %Y %I:%M%p')
event['end']['utc']=str(enddate.date())+'T'+str(enddate.time())+'Z'
#event['end']['utc']=enddate.isoformat()+"Z"
event['end']['timezone']=event['start']['timezone']
event['currency']=input("3 letter code")
response = requests.post("https://www.eventbriteapi.com/v3/events/",
headers = {
"Authorization": "Bearer NC.....",
"Content-Type" : "application/json"
},
data=json.dumps({"event":event}),
verify = True, # Verify SSL certificate
)
Strictly followed the docs https://www.eventbrite.com/developer/v3/endpoints/events/
According to docs datatype of event.start.utc and event.start.end data shall be datetime i.e "2010-01-31T13:00:00Z"
We can see in the comments I also tried with isoformat function.
On printing event object I found the same format as specified in the docs.
But receiving response.content as event.start invalid argument or event.start.utc as datetime wrong format use instead "YYYY-MM-DDThh:mm:ssZ" !!
I ran into date issues with Eventbrite too; after debugging found this to work for events:
{ event:
{ name: { html: 'Postman API Event!' },
description:
{ html: 'My fav event is The Winter Formal.' },
start: { timezone: 'America/Los_Angeles', utc: '2018-09-06T00:19:53Z' },
currency: 'USD',
listed: false,
end: { timezone: 'America/Los_Angeles', utc: '2018-09-06T00:20:53Z' } } }
and of course, different date formats in another part of API ;-)
Regarding discounts / cross event discount, where the docs specify a
Naive Local ISO8601 date and time format
First I've heard of the 'Naive' format? Why no example Eventbrite? Here's what worked:
2018-10-11T12:13:14
I have to disable past dates in Eonasdan bootstrap datetimepicker v4,
My Code is :
$('input#startDate,input#endDate').datetimepicker({
format: 'DD/MM/YYYY hh:mm:ss',
startDate: new Date()
});
$('#datetimepicker').datetimepicker({
minDate:new Date()
});
I am using a datepicker in titanium iOS to read date.
When I am trying to set a value to the date picker t wont work.It is always showing the maxDate.
What is the actual solution for this
//my sample code of picker is follows
var picker2 = Ti.UI.createPicker({
type: Ti.UI.PICKER_TYPE_DATE,
selectionIndicator: true,
minDate: new Date(moment().subtract(120, 'years')),
maxDate: new Date(moment().subtract(18, 'years')),
value: new Date(2014,3,12),
//value: navHistory == 'profilePage' && dateofbirth !=null ? dateofbirth : new Date(moment().subtract(18, 'years')),
top: Ti.Platform.displayCaps.platformHeight / 30,
});
The reason your current solution does not work is because your value is actually a date after your maxDate (hence it will set the value to maxDate). You need to use a date within minDate and maxDate as value for it to work.
For example:
var picker = Ti.UI.createPicker({
type: Ti.UI.PICKER_TYPE_DATE,
selectionIndicator: true,
minDate: new Date(moment().subtract(120, 'years')),
maxDate: new Date(moment().subtract(18, 'years')),
value: new Date(1990,3,12)
});
I am having trouble to get my filter of a defect store working. I am trying to to get all the defect that are created after a specific date( Release.ReleaseDate ).
_getFilters: function(startDate) {
var dateFilter = Ext.create('Rally.data.wsapi.Filter', {
property: 'CreationDate',
operator: '>',
value: startDate
});
console.log('startDate is: ', startDate); //Sat Aug 23 2014 02:59:59 GMT-0400 (Eastern Daylight Time)
console.log(dateFilter.toString());
return dateFilter;
},
With the above filter, I always get an empty result, even thought I have verified that there are indeed some defects that are created after the startDate.
Note: If I remove the filter in the store config, I do see a list of defects.
Am I missing anything?
Thanks
The date has to be converted to ISO format. Assuming you got the release object:
var releaseStartDate = release.get('ReleaseStartDate');
var releaseStartDateISO = Rally.util.DateTime.toIsoString(releaseStartDate,true);
your filter will include this:
{
property : 'CreationDate',
operator : '>',
value : releaseStartDateISO
}
A full example is in this github repo.
It turns out that I need to 'reformat' the startDate to the following form before passing it to the filter.
YYYY-MM-DD