change date format
-
hi there,
how can i change the date format of the calculated cdate function?
from 01/01/2014 to 1. January 2014
best regards
-
Hi,
Do you want display this date format in the calculated field?
I’ll describe a situation, that you should adjust it to your particular equation.
If your current equation is something similar to: CDATE(…)
You should modify the equation like follow:
(function(){
var d = new Date( CDATE(…));
return d.toDateSting();
})()Now, you should open the “module_public.js” file, located in “/wp-content/plugins/calculated-fields-form/js/modules/01_mathematical_logical/public/module_public.js”, in the text editor your choice, and modify the snippet of code:
‘validator’ : function( v )
{
return isFinite( v ) || /\d{2}[\/\-\.]\d{2}[\/\-\.]\d{4}/.test( v );
}like follow:
‘validator’ : function( v )
{
return typeof v != ‘undefined’;
}Best regards.
Thanks for your reply.
Yes, i want to display this date format in a calculated field. I copied your suggestion into my cal field and modified the snippet of code.
Result: nothing, i got a white field.my equation:
(function(){
var d = new Date( CDATE(fieldname1+280+fieldname7));
return d.toDateSting();
})()Fieldname1 is a date and fieldname2 is a value (from -7 til +12)
Hi,
Could you send me a link to your page to check the issue in detail, please?
Best regards.
sry, its local. is it possible to export the calculator?
Hi,
I’m sorry, my mistake. I’ve typed wrong the method name. Please, use the following equation, pay attention to the date format, passed as the second parameter of the CDATE operation:
(function(){
var d = new Date( CDATE(fieldname1+280+fieldname7,’mm/dd/yyyy’));
return d.toDateString();
})()Best regards.
ok it works fine.
but where can i but my german time format? d. F Y ?
Hi,
In this case you should formatting the text by yourself:
(function(){
var month_names = [‘January’, ‘February’, ‘March’, ‘April’, ‘May’, ‘June’, ‘July’, ‘August’, ‘September’, ‘October’, ‘November’, ‘December’];
var d = new Date( CDATE(fieldname1+280+fieldname7,’mm/dd/yyyy’));
return d.getDate()+’. ‘+month_names[d.getMonth()]+’ ‘+d.getFullYear();
})()Best regards.
Nice one. Thanks a lot.
Hi,
A good rating is always appreciated 😉
Best regards.
there is one other thing, than you’ll get your rating 😉
what is the parameter for today?
I want to calculate a figure of weeks from now.
case: 40-(280-(todays date – formfield)/7)
with no decimal.
Hi,
You are using the free version of plugin (in the developer version there are specific operations for dates). So, in this case you can insert another date field, without define a default date (the default values in date fields is the today date), and use the new field in the equation.
If the field for today is important only for the equations, and it does not have any other functionality in the form, you can hide the field from the public webpage simply assigning a classname through the “Add Css Layout Keywords” attribute of the field, for example, myclass, and define the new class in any css file of your website:
.myclass{display:none;}
Best regards.
ok, using a hidden field was my plan b 😉
hoped that there is a today dates paramaeter. but ok, no problem.
thanks for your work!
The topic ‘change date format’ is closed to new replies.