how do I display in a cakephp form value from orm in date format - cakephp

I have the below code in a cakephp templage
echo $this->Form->input('Applicant.application_date',array('between'=>$star,))
the value from the database is a date type and the form displays it as a series of dropdown for the month date and year
how do i make it display as a date picker or just an input box with values in the format DD/MM/YYYY

To display a datepicker, you can add a piece of javascript.
Here is a sample with jquery :
Template:
$this->Form->control("horaire",[
'value'=>$horaire
]);
Javascript part:
$("#horaire").datetimepicker({
dateFormat : "dd/mm/yy",
timeFormat: 'HH:mm',
hourGrid : 4,
minuteGrid : 10,
stepMinute: 5,
hour : 20,
minute : 0
});

Related

react-day-picker changing default date format prevents entering date

I have just started using the react-day-picker library. I have the following code sandBox which is a fork of the range with 2 inputs example,
https://codesandbox.io/s/w6vnlox29l
I have it working the way I want but I want to input the dates as MM/DD/YYYY instead of the default format, YYYY-MM-DD. When I add the following attributes
<DayPickerInput
value={from}
format="M/D/YYYY"
formatDate={formatDate}
parseDate={parseDate}
placeholder="MM/DD/YYYY"
onDayChange={this.handleFromChange}
dayPickerProps={{
selectedDays: [from, { from, to }],
modifiers,
disabledDays: {
after: new Date(),
},
numberOfMonths: 2,
toMonth: new Date(),
}}
/>
I can no longer correctly enter the date in the input field the date. When I remove the format, formatDate and parseDate attributes the date picker input functions the way I expected. I have read the documentation but think I may be missing something simple. How can I use the input text box and date picker with dates formatted as MM/DD/YYYY?

Ionic Timepicker Default Value

In my ionic app, I have a timepicker, how can I set the default time to be displayed as 10am ?
This field will be displaying the data from database if any, or as a new field to be saved.
Below is my html code
<div class="fortimepicker" ion-datetime-picker ng-model="ship.fromtimeValue">{{ship.fromtimeValue| date: "yyyy-MM-dd hh:mm a"}}</div>
You can set your default time in the angular ng-modal like
<div class="fortimepicker" ion-datetime-picker ng-model="fromtimeValue">{{fromtimeValue | date: "yyyy-MM-dd hh:mm a"}}</div>
and set the ng-model in js like:
$scope.fromtimeValue = new Date("October 13, 2014 10:00:00");//or the default date-time you want set
After this if you open the picker it will come with the default time '10:00'
If you want to check the working example i have added your code in the codepen ion-datepicker demo : http://codepen.io/anon/pen/JXvWdQ , where you can check the first line which comes with 10:00 as default time

How update/refresh options dynamicaly datetimepicker

Is there any way to update the option(s) of datetimepicker dynamicaly ?
In my case, on start, i setting my "busy dates" array in the option **disabledTimeIntervals ** of the plugin. It working fine but when I change my differents dates, I update the "busy dates" array and I try to set new option disabledTimeIntervals by passing the updated array each time I change the date like this :
$scope.options = {
locale: 'fr',
sideBySide: true,
format: 'DD/MM/YYYY à HH:mm',
useCurrent: false,
daysOfWeekDisabled: [0, 6],
stepping: 15,
disabledTimeIntervals: $scope.getBusyDates(),
ignoreReadonly: true
};
element.datetimepicker(eval($scope.options));
Unfortunatly that doesn't work and datetimepicker ignore my news settings ... How I can force datetimepicker to review the options when I want ? thank's
Response : For set this new option I have to use the Option function : (http://eonasdan.github.io/bootstrap-datetimepicker/Functions/#options)
So, the correct syntaxe response is :
element.data('DateTimePicker').options(eval(scope.options));

Angular pikaday date formatting

I'm using angular-pikaday plugin (https://github.com/nverba/angular-pikaday) and I have a problem with a date formatting.
What I need to get is a model with a string of date in format YYYY-MM-dd.
I've installed Moment.js through bower (as documentation says that it's needed). Part of code looks like this (angular-pikaday.coffee)
picker = new Pikaday(
field: elem[0]
trigger: document.getElementById(attrs.triggerId)
bound: attrs.bound isnt "false"
position: attrs.position or ""
format: "YYYY-MM-dd" # Requires Moment.js for custom formatting
defaultDate: new Date()
setDefaultDate: attrs.setDefaultDate is "true"
firstDay: 1
( ... )
How can I put formatted date inside ng-model passed in HTML?
Date = {{ myPickerObject.getDate() | date:'YYYY-MM-dd' }}
UPD:
$filter('data')(myPickerObject.getDate(), 'YYYY-MM-dd' )

How to keep the format of ExtJS timefield in 24hours

I am trying to create a timefield combo box with extJS. I have done this successfully but now I have a problem when I get the value that I select in the combo box.
First the code for making the timefield:
items :[{
fieldLabel: 'Start Time',
name: 'startTime',
xtype: 'timefield',
id: 'startTime',
format: 'H:i',
altFormats:'H:i',
increment: 30
}]
What I want is to get the value in a 24h format. In order to get the value from the time field I use this code:
var startTime = Ext.getCmp('startTime').getSubmitValue();
The problem is that instead of getting the time in 24hour format, the values are transformed into 12 hours format. For example, while I select from the combo the time: 00:00 when I use getSubmitValue() the value is transformed into 12:00 AM, which is not very useful in my case.
My question is: Is there a way to keep the format of the time exactly how it is in the combo box? That would be a 24hour format.
I hope it's clear what I am trying to say.
Thanks
Dimitris
The reason is simple.
getValue returns date object, getSubmitValue returns formatted date.
You just need to format a date received by getValue method.
var field = Ext.getCmp('startTime');
var value = field.getValue();
var formattedValue = Ext.Date.format(value, 'H:i');
Sample here
I found out that if I use the:
var startTime = Ext.getCmp('startTime').getRawValue();
I retrieve the time in 24 format.

Resources