I'm using Liferay 7.1 I have the following liferau-ui:input-date object and I want to pre-select a date:
<%
final LocalDate today = LocalDate.now(ZoneId.systemDefault());
%>
<liferay-ui:input-date
dayValue="<%= today.getDayOfMonth()%>"
monthValue="<%=today.getMonth().getValue()%>"
yearValue="<%= today.getYear()%>"
</liferay-ui:input-date>
When I output today's values directly on the JSP I get the correct date for today: 3 12 2018.
When the element is rendered, it has selected the wrong date: 01/03/2019. There is nothing further documented in the taglibdocs that I think could help.
How can I fix this?
The problem is the month value. In Java it's 1-12 with liferay datepicker it's 0-11.
In order to display the correct month i subtracted 1 from month value. It's not an elegant solution but i couldn't find any better way.
<liferay-ui:input-date
dayValue="<%= today.getDayOfMonth()%>"
monthValue="<%=today.getMonth().getValue() - 1 %>"
yearValue="<%= today.getYear()%>"
</liferay-ui:input-date>
This will render 12/03/2018
Related
Consider the following code
<v-date-picker
v-model="picker"
:first-day-of-week="6"
locale="fa"
></v-date-picker>
<v-date-picker
v-model="picker"
></v-date-picker>
As you can see in the following picture, In Persian calendar month starts by 12th which is the first day of May
Code Output, Left side is Persian calendar
I also have this problem, unfortunately it's an open bug in Vuetify:
[Bug Report] Problem with vuetify Persian datepicker year selection #11578
Which is a duplicate of:
[Bug] Date picker new month is started at the end of previous month in 'FA-local'.
Personally, I had to user vue-persian-datetime-picker. It's pretty good, a simple api and easily customizable. Still, I hope they fix the problem with v-date-picker
I am creating an acceptance test in Cypress that will run regularly, and I need that it enters the date from the datepicker (React, if it is important) as 1 year 1 month and 1 day from the day of creating the object (article). E.g. Today is April 22, 2020, and I want to get May 23, 2021 in the article created today, and tomorrow it would give the value of May 24, 2021 etc. Could anyone share any ideas of setting this up? I honestly googled and I have no ideas myself because I'm quite new to Cypress and feel more or less confident only in pretty straightforward things. :)
I'd guess that most date pickers will have an input element where the date can be typed.
Presuming the app uses a library date picker (so you don't need to test the picking of the date via button clicks), you can target that element and use the Cypress .type() command to enter the future date.
For example, the Material UI date picker docs has this input element
<input aria-invalid="false"
id="date-picker-inline"
type="text"
class="MuiInputBase-input MuiInput-input MuiInputBase-inputAdornedEnd"
value="08/18/2014">
so the steps would be something like
cy.visit('https://material-ui.com/components/pickers');
const targetDate = Cypress.moment()
.add(1, 'year')
.add(1, 'month')
.add(1, 'day')
.format('MM/DD/YYYY') // adjust format to suit the apps requirements
cy.get('input[id="date-picker-inline"]')
.clear()
.type(`${targetDate}{enter}`) // presume you need the enter key to trigger an event
Ref: Cypress.moment
This method was deprecated. You can use this method;
//click the date picker
cy.get('#datepicker').click();
//choose previous month
cy.contains('Prev').click();
//choose next month
cy.contains('Next').click();
//choose date 24
cy.contains('24').click();
I am trying with the telerik kendo ui for angular 2 (http://www.telerik.com/kendo-angular-ui/)
working on the datepicker, don't know why it looks like the datepicker adds one month to the binding value. As you see it in this plunker http://plnkr.co/edit/8yUqiagcZ957saufxYpS?p=preview
The date is set to new Date(2000, 2, 10); but the control displays 03/10/2000.
I want it displays exactly as set( e.g 02/10/2000). How can I do?
JavaScript Date object accepts zero-based month values, unlike the days and years for instance.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
That being said, just pass 1 to display "February".
new Date(2000, 1, 10)
http://plnkr.co/edit/pb09ZPo4L18ExGYOcu4x?p=preview
I have a question about the date format in smarty.
I got a smarty variable: [{ $order->oxorder__oxorderdate->value }]
This variable give me: 2013-03-10 10:45:17
Now I want do add 14 days, remove the time and change the format of the date:
So my wish is now to get this: 24.03.2013
Is this possible and how can i do this directly in the smarty/.tpl file?
Thank you for help and greetings!
Tested in Smarty 3
{"$order->oxorder__oxorderdate->value +14 Days"|date_format:'d.m.Y'}
I think a found a food way to do that :
{assign var="date" value= $order->oxorder__oxorderdate->value|#strtotime + (60*60*24*7)}
{assign var="date2" value=$date|date_format:"%d/%m/%Y"}
{$date2}
Change 7 value par the day you want ;-)
I'm trying to set the format for a jquery datepicker element with the date format returned by Zend_Locale::getTranslationList('date', $locale);
My problem is zend returns the string 'dd/MM/yyyy' for the date format but jquery expects only 2 characters for the year ie 'dd/mm/yy', so it enters the year twice 20112011
Is there some option that can be passed to either zend or jquery to make them work in the same manner? I've read through the docs and can't seem to find anything
Many thanks for your help in advance!
I have used jquery date picker in python-django framework when I give date format as dd/mm/yyyy format it returns 20112011 then i have corrected it to dd/mm/yy and it returned 2011 only. you can specify in your datepicker css class to specify the date format as dd/mm/yy.
Iam not sure if this is what you're looking for but:
// use german local, change it to our needs :-)
$locale = new Zend_Locale('de_DE');
$result = Zend_Locale::getTranslationList('date', $locale);
// returns dd.MM.yy (german!)
echo $result['short'];