• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Calendar Default Value date format not working

Calendar Default Value date format not working 17 years 5 months ago #1251

  • gardar
  • gardar's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
Hi,

I'm trying to change the date format putting the following into the Default Value field for the Calendar:

d/M/y

But it doesn't work, the date format sent via the form is still m/d/y.

What am I missing?
Is there a prefix in front of the field text?
What is the exact syntax?
How do I make the form output d/M/y ?

Regards,
Gardar



Adds a Calendar Input.
Add as Default Value the date format.
Keys:
m - 1..12
M - Jan..Dec
mm - 01..12
d - 1..31
dd - 01..31
D - Mon - Sun
y - xxxx
Example: m/d/y
The administrator has disabled public write access.

Re:Calendar Default Value date format not working 17 years 5 months ago #1261

  • alex
  • alex's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 443
  • Thank you received: 3
Hi Gardar,

unfortunately the calendar syntax does not work in this version. Anyhow, if you wish to change it please do this(it's a bit complicated and i promise i'll fix it for the next version):

Edit your form, and go to the Scritps tab. In the Scripts called on form process: add this code:
if(isset($_POST['form']['yourcalid'])){
   $_POST['form']['yourcalid'] = date('d/m/Y',strtotime($_POST['form']['yourcalid']));
}
Replace yourcalid with whatever your field id is, and replace 'd/m/Y' with the format you want to have. Take a look at www.php.net/manual/en/function.date.php to see what syntaxes you can use.<br><br>Post edited by: alex, at: 2007/11/20 14:24
The administrator has disabled public write access.

Re:Calendar Default Value date format not working 17 years 5 months ago #1264

  • gardar
  • gardar's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
Great!
Worked like a charm.
Thank you for a fantastic product.

Gardar
The administrator has disabled public write access.

Re:Calendar Default Value date format not working 17 years 2 months ago #2183

  • yksur
  • yksur's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 6
This is not working for me.
I have a form called 'prenotazione' (id 1) and 2 calendar id 'Arrivo' and 'Partenza'.

I tried to change everything into above code but nothing.
My emails come always in m/d/y and not d/m/y.

Alex can you help?

Thanks in advance.
The administrator has disabled public write access.

Re:Calendar Default Value date format not working 17 years 2 months ago #2203

  • aphid
  • aphid's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 14
Hi gardar

I've mentioned this in another post as I can't get this work either. I'm surprised that more people haven't wanted to change date format. Or they found a get around.
My only other theory is that they live in countries where the system date in already as they want i.e. M/d/y. But there are some clever guys here, so perhaps we'll find a solution.

Maybe you should ask support?

Regards

Peter
The administrator has disabled public write access.

Re:Calendar Default Value date format not working 17 years 1 month ago #2269

  • aphid
  • aphid's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 14
Hell yksur

Did you find a solution? Unfortunately for some reason the code that Alex supplied is not working for me at all. Yet looking at it, it should work... I have found a get around by hacking the forme.html.php file. It will give you dd mm yy date format. Note: there is no guarantee as it's not fully tested, but maybe this will work for you. I'll post it if you're interested?


Peter
The administrator has disabled public write access.

Re:Calendar Default Value date format not working 16 years 11 months ago #2994

I have tried the code that has been suggested (at the top of this thread and via the Knowledgebase) but neither of them work. I have emailed several times for support too but not had a response :(

My client is getting really aggitated now and keeps asking why we can't change the format. It should be so simple.

I would be really grateful if you could post your workaround.

The two snippets of code we've tried are:-
if(isset($processform['form']['yourcalid'])){
    $date = explode('/',$processform['form']['yourcalid']);
    $processform['form']['yourcalid'] = date('d/m/Y',strtotime($date[2].'-'.$date[1].'-'.$date[0]));
}

and this, which we can't eben Apply/Save. When you add it to the Scripts section and click 'Save', the page displayed says '501 - Post - \"Method Not Implemented\"'
if(isset($_POST['form']['yourcalid'])){
   $_POST['form']['yourcalid'] = date('d/m/Y',strtotime($_POST['form']['yourcalid']));
}
The administrator has disabled public write access.

Re:Calendar Default Value date format not working 16 years 11 months ago #3005

No response from support for two weeks so had to dig around myself.

Managed to change from m/d/Y to d/m/Y by editing the forme.html.php file in the components folder
function handleSelect&lt;?php echo $field-&gt;name;?&gt;(type,args,obj) {
var dates = args[0];
var date = dates[0];
var year = date[0], month = date[1], day = date[2];
var txtDate = document.getElementById(\&quot;txt&lt;?php echo $field-&gt;name;?&gt;\&quot;«»);
 // txtDate.value = month + \&quot;/\&quot; + day + \&quot;/\&quot; + year;  	// This was the original line
txtDate.value = day + \&quot;/\&quot; + month + \&quot;/\&quot; + year;        // Changed the day and month around
 

It is an excellent tool though and we wouldn't hesitate to purchase more copies (which I'm sure we will do shortly) - despite a couple of glitches we've had.

Post edited by: stuart.w.brown, at: 2008/05/20 22:23<br><br>Post edited by: stuart.w.brown, at: 2008/05/20 22:25
The administrator has disabled public write access.

Re:Calendar Default Value date format not working 16 years 5 months ago #5480

Thank you Stuart, your hack is very appreciable, but do not help me to solve this old issue here. :dry:

I'm still get the \"m/d/y\" format instead \"d/m/y\"

any advice?


Have a nice time!<br><br>Post edited by: luciano.bergesch, at: 2008/11/11 15:59
The administrator has disabled public write access.

Re:Calendar Default Value date format not working 16 years 5 months ago #5819

Found! :laugh:

The fix wasn't work because I'm using the BOT to load forms into my page contents, so I edited the plugin file the same way and now I get it ok!

plugin file: mosforme.php

around line 174:

change the line
txtDate.value = month + \"/\" + day + \"/\" + year;

to this line line
txtDate.value = day + \"/\" + month + \"/\" + year; // force date format
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!