Bootstrap-datepicker and multidate values in input field - bootstrap-datepicker

I use Bootstrap-datepicker with embedded and multidate options.
I would like that chosen dates appear in the input field. How to do this?
I try this code but only one date appear :
$('#date').datepicker().on('changeDate', function(e){
$('#date_input').val(e.format('mm/dd/yyyy'));
});
With this other solution, the date format is not convenient for me :
$('#date').datepicker().on('changeDate',function(){
var value=$("#date").datepicker("getDates");
$('#date_input').val(value);
});
I also love the format is as follows: dd/mm/yyyy
For instance : 06/07/2014, 07/07/2014, 10/07/2014
Can you help me please?
In advance thanks a lot for your answers

var picker = $('#picker').datepicker();
console.log( picker.datepicker('getFormattedDate') );

Related

Check if date valid using moment and format 'YYYY-MM-DDThh:mm:ss.SSS+ss:ss' does not work

I'm trying to check if a string YYYY-MM-DDThh:mm:ss.SSS+ss:ss
But I always get false.
For example:
const value = '2022-02-16T22:23:53.000+00:00'
moment(value, DATE_FORMAT, true).isValid();
Please advise, am I using the wrong format ?
Date format should have been - YYYY-MM-DDTHH:mm:ss.SSSZ

How to get the actual meridiems in luxonjs?

So i tried to get the meridiems on luxon.js because i'm going to move my discord.js bot that is using momentjs to luxonjs because i like it more. But i got the problem that i just can't figure out how to get the meridiems of the timezone that i especify, could you help me out?
I've tried
Info.meridiems()
but i don't know how to use or what do i do with the Info part,
And then i don't understand the parameters that the give in their documentation as an example
Info.meridiems({ locale: 'my' })
it was kinda easy but i will not delete this post if someone needs it.
Basically what i did is to get the date in the format that i wanted
const time = DateTime.local().setZone('tz').toFormat("HHmmss");
in .setZone('tz') you should just put the time zone you want according to the luxon docs.
Then i would just use an if for it
const smartMeridiems = (am, pm) =>{
if(time > 120000){
pm = 'PM'
return pm;
} else{
am = 'AM'
return am;
}
}
And that is basically it
The meridiem for a DateTime can be accessed by the "a" format token:
DateTime.local().setZone(z).toFormat("a") //=> "PM"
The Luxon Info methods are for finding out what the meridiems are called in different human languages.

datesDisabled Bootstrap-DatePicker

There are plenty of questions on this but none of them seem to have worked for me.
I will eventually have an array of dates being passed in for multiple days over different months.
I'm using this version of the bootstrap datepicker
https://bootstrap-datepicker.readthedocs.io/en/latest/
looking over the docs, a simple array of dates for'disabledDates' should be all it needs to get these working, but I'll be damned if it accepts it.
Any ideas as to why it doesn't work?
var disabledDates = ['28/3/2018','22/3/2018'];
$('.datepicker').datepicker({
format: 'DD/MM/YYYY',
maxViewMode: 1,
todayBtn: "linked",
clearBtn: true,
multidate: true,
daysOfWeekDisabled: "0,6",
datesDisabled: disabledDates
})
In disabledDates variable you used dates like '28/3/2018' and '22/3/2018'. According to the doc these dates are in this format d/m/yyyy or dd/m/yyyy.
But, inside datepicker() function you have declared the date format as DD/MM/YYYY.
Try to change the date format format: 'DD/MM/YYYY', to format: 'd/m/yyyy', or format: 'dd/m/yyyy',

Reformatting date in google spreadsheet

I'm setting up a spreadsheet for someone else with a form to enter data.
One of the columns is supposed to hold a date. The input date format is like this example: "Jan 26, 2013" (there will be a lot of copy & paste involved to collect data, so changing the format at input step is not a real option).
I need this date column to be sortable, but the spreadsheet doesn't recognize this as a date but simply as a string. (It would recognize "Jan-26-2013", I've tried.)
So I need to reformat the input date.
My question is: how can I do this? I have looked around and google apps script looks like the way to go (though I haven't found a good example of reformatting yet).
Unfortunately my only programming experience is in Python, and of intermediate level. I could do this in Python without a problem, but I don't know any JavaScript.
(My Python approach would be:
splitted = date.split()
newdate = "-".join([splitted[0], splitted[1][:-1], splitted[2]])
return newdate
)
I also don't know how I'd go about linking the script to the spreadsheet - would I attach it to the cell, or the form, or where? And how? Any link to a helpful, understandable tutorial etc. on this point would help greatly.
Any help greatly appreciated!
Edit: Here's the code I ended up with:
//Function to filter unwanted " chars from date entries
function reformatDate() {
var sheet = SpreadsheetApp.getActiveSheet();
var startrow = 2;
var firstcolumn = 6;
var columnspan = 1;
var lastrow = sheet.getLastRow();
var dates = sheet.getRange(startrow, firstcolumn, lastrow, columnspan).getValues();
newdates = []
for(var i in dates){
var mydate = dates[i][0];
try
{
var newdate = mydate.replace(/"/g,'');
}
catch(err)
{
var newdate = mydate
}
newdates.push([newdate]);
}
sheet.getRange(startrow, firstcolumn, lastrow, columnspan).setValues(newdates)
}
For other confused google-script Newbies like me:
attaching the script to the spreadsheet works by creating the script from within the spreadsheet (Tools => Script Editor). Just putting the function in there is enough, you don't seem to need a function call etc.
you select the trigger of the script from the Script Editor (Resources => This Project's Triggers).
Important: the script will only work if there's an empty row at the bottom of the sheet in question!
Just an idea :
If you double click on your date string in the spreadsheet you will see that its real value that makes it a string instead of a date object is this 'Jan 26, 2013 with the ' in front of the string that I didn't add here...(The form does that to allow you to type what you want in the text area, including +322475... for example if it is a phone number, that's a known trick in spreadsheets cells) You could simply make a script that runs on form submit and that removes the ' in the cells, I guess the spreadsheet would do the rest... (I didn't test that so give it a try and consider this as a suggestion).
To remove the ' you can simply use the .replace() method **
var newValue = value.replace(/'/g,'');
here are some links to the relevant documentation : link1 link2
EDIT following your comment :
It could be simpler since the replace doesn't generate an error if no match is found. So you could make it like this :
function reformatDate() {
var sheet = SpreadsheetApp.getActiveSheet();
var dates = sheet.getRange(2, 6, sheet.getLastRow(), 1).getValues();
newdates = []
for(var i in dates){
var mydate = dates[i][0];
var newdate = mydate.replace(/"/g,'');
newdates.push([newdate]);
}
sheet.getRange(2, 6, sheet.getLastRow(), 1).setValues(newdates)
}
Also, you used the " in your code, presumably on purpose... my test showed ' instead. What made you make this choice ?
Solved it, I just had to change the comma to dot and it worked

How to set default sort column in extjs4 grid and change date format?

1-How do I set the column to be sorted when the grid is created? then upon reloading the grid, it automatically utilize that sort to appropriately display the records.(without me clicing on it)
Can this be done on the grid itself so it is independent of the underlying data store?
2-how do i change Date format displaying in a grid column?
my data render a date like this /Date(1316020760837+0000)/
i tried using renderer: Ext.util.Format.dateRenderer('m/d/Y'),// format: 'm d Y'
but it gives me NaN/NaN/NaN
any help would be appreciated.
thank you
solved:
i used sortOnLoad with sorters
var myStore = new Ext.data.JsonStore({
fields: ['Item1', 'Item2', 'Item3', 'Item4']
, data: []
, sortOnLoad: true
, sorters: { property: 'Item1', direction : 'DESC' }
});
in my c# code i used item.DateEnd.ToString("MMM dd, yyyy").
see this or this for standard and custom format
or better
in extjs4 ,you should specify the dateFormat so Ext can parse it properly and you'll ensure it gets read ok.
{name: 'Item1' , type : 'date',dateFormat :'MS'}
u can see this for available format strings.

Resources