I am working with Kendo date picker.I am trying to disable the dates before 2000-01-01. Is it possible with Kendo date picker?
You can simply set the min value of the date picker:
// set the min date to Jan 1st, 2011
$("#datePicker").kendoDatePicker({
min: new Date(2000, 0, 1),
// other config options
});
Related
from php I write like this :
$date = new \DateTime('2019-11-15 23:00:00', new \DateTimeZone('UTC'));
$result = [
'id' => $auction->getId(),
'endDate' => $date,
];
Now in the api I saw :
endDate : 2019-11-15T23:00:00+00:00
In my linux vps when I wrote date I get :
Fri Nov 15 20:27:50 UTC 2019
The problem is that on front I have a countdown, and on every endDate is adding 2 hours and I don't understand why.
Your front will diplay the date in YOUR time zone.
In you database or backend, the date is stored with the default time zone.
Here is an example:
const date = '2019-11-15T23:00:00+00:00'
diffWithYourTimeZone = new Date(date).getTimezoneOffset();
console.log(diffWithYourTimeZone)
// You will probably see 120(min) or -120(min)
If you do console.log(new Date()) in your navigator, you will have something like this xxx xxx xx 2019 HH:MM:MiMi GMT+0200 (...) it means that you are in the zone +2H from GMT(Greenwich Mean Time). When you store data in your backend, it's always as GMT + 0. But for your user in the front, you want to dsplay their date and time. This is why your navigator convert your date in GMT + 0 in the time in GMT + 2.
in my date form input i will select only month and year but when i insert into database its saving month and year with current date. but i want set date 1st of slected month im using carbon also
{!! Form::text('vessel_date',null,['class' => 'date-own form-control' , 'id'=>'date-own-id']) !!}
Controller :
$input['vessel_date'] = Carbon::createFromFormat('m-Y', $request->vessel_date)->toDateString();
JS :
$('.date-own').datepicker({
minViewMode: 1,
format: 'mm-yyyy'
});
Here is an example of how I have used Carbon to get the first of the month in a recent application:
// (year, month, day)
Carbon::createFromDate(null, null, 1)
Year, Month, and Day being integers.
To format before insert/update (depending on target DB format) ->format('M d Y')
you can try this. you can find it here.
$('.datepicker').datepicker('update');
$('.datepicker').datepicker('update', '2011-03-05');
$('.datepicker').datepicker('update', new Date(2011, 2, 5));
Just to add to the answer above my comment, also kindly check your date format of your DBMS (e.g if it is same with your datepicker).
answer is
$('.date-own').datepicker({
minViewMode: 1,
format: 'mm-yyyy'
});
I've been trying to obtain the selected date on Yii's DatePicker widget because I need to convert it to the year's week to which the selected date belongs. The first time I load the page, it properly displays the corresponding week according to the day (i.e. Today's october 15th, 2015 properly displays Week 42), but I can't figure out how to make it display the week of the new selected date. I've tried 'submit' buttons and the onSelect function with no success. Thanks for your help.
Here is the widget's code.
<?php $this->widget("zii.widgets.jui.CJuiDatePicker", array(
"name"=>"reserva[fecha]",
"attribute"=>"fecha",
"model"=>$reserva,
"value"=>$reserva->fecha,
"language"=>"es",
"options"=>array(
'altField'=>'#some_selector',
"dateFormat"=>"dd-mm-yy",
'showButtonPanel'=>true,
'changeYear'=>true,
'changeMonth'=>true,
'selectOtherMonths'=>true
)
)
);
And here's the Date -> Week of the Year convert code.
ddate = $reserva->fecha;
$date = new DateTime($ddate);
$week = $date->format("W");
echo "Semana: $week";
The following worked for me when working with CJuiDatePicker
$date = date('W',strtotime($ddate))
i have used a date picker from bootstrap. I was wondering how would i exclude the 10 days from the selected day the user has clicked
for example the user chooses 10th April 2015. That user can only select dates from 10th April 2015 - 19th April 2015 which would be the ending date.
Here is my code for the date picker.
<script type="text/javascript">
var nowDate = new Date();
var today = new Date(nowDate.getFullYear(), nowDate.getMonth(), nowDate.getDate(), 0, 0, 0, 0);
$(function () {
$('#startdate').datetimepicker({
minDate:today,
format: 'YYYY-MM-DD HH:MM:SS'
}).change(function (selected) {
var startDate = new Date(selected.date.valueOf());
$('#enddate').datetimepicker('maxDate', startDate+10);
});
$('#enddate').datetimepicker({
minDate:today,
format: 'YYYY-MM-DD HH:MM:SS'
});
});
</script>
Option "enabledDates", disables selection of dates NOT in the array, perhaps that will work for you?
http://eonasdan.github.io/bootstrap-datetimepicker/Options/#enableddates
I have this kind of time format, it is stored in my database.. And I want to convert it to a format that jQuery countdown accepts.. I think jQuery countdown accepts this kind of format
Sun Jan 01 2012 00:00:00 GMT+0800 (Malay Peninsula Standard Time)
But the problem is, my time format is like this:
2011-03-29 00:01:03
In order for jQuery countdown to make a countdown, I need to convert that to that long format.. How to do it?
Here's the website of jQuery countdown
Split your format then create a new Date() and pass it to the countdown constructor:
$dateAndTime = '2011-03-29 00:01:03'.split(" ");
$date = $dateAndTime[0].split("-");
$time = $dateAndTime[1].split(":");
// Date(year, month, day, hours, minutes, seconds)
$(selector).countdown({
since: new Date( $date[0], (intval($date[1]) - 1), $date[2], $time[0], $time[1], $time[2])
});
You don't need it in that long format, that is what is just the format that is output when you try to print a Javascript Date object.
You need to create a Javascript Date object
The native way to do that is like so:
var date = new Date([year], [month], [day]);
Note: the month is zero indexed. i.e. January is 0, February is 1, December is 11.
So if you were spitting this out using php.
$date = new DateTime('2011-03-29 00:01:03');
printf('var date = new Date(%d, %d, %d);',
$date->format('Y'),
$date->format('n') - 1,
$date->format('j'),
$date->format('H'),
$date->format('i'),
$date->format('s')
);
Alternatively you could pass it using json:
json_encode(array(
'year' => $date->format('Y'),
'month' => $date->format('n') - 1,
'day' => $date->format('j')
'hour' => $date->format('H'),
'minute' => $date->format('i'),
'second' => $date->format('s')
));
then create the Date with Javascript:
var date = new Date(json.year, json.month, json.day,
json.hour, json.minute, json.second);