Please read and follow the COMMON ISSUES first!
Always add your version information in every new post! Thank you!

Form2Content Forum

Questions and answers for Form2Content, a Joomla CCK.
  1. Eric
  2. F2C field types
  3. Saturday, 10 August 2013
  4.  Subscribe via email
Is it possible to change the way the date from the date picker field is formatted?
I would like it to change from 01-01-1900 to Saturday 1 January 1900.

Joomla 2.5.14 - F2C Pro 4.7

Rgds, Eric
Accepted Answer
F2C webmaster Accepted Answer Pending Moderation
Hi Eric,

Have a look at this article for some more date formats.

Regards,
Patrick
References
  1. http://documentation.form2content.com/documentation/f2c-smarty-code-snippets/110-displaying-date-fields-as-textual-dates-in-smarty-templates
Please read the F2C documentation before asking questions! Thank you if you've done so ;)
  1. more than a month ago
  2. F2C field types
  3. # Permalink
Responses (5)
Julien Accepted Answer Pending Moderation
Hi Eric,

Which date format do you want to change?
The format that is shown while picking the date or the format of the output of the template parameter for the date picker field?

best,
Julien
  1. more than a month ago
  2. F2C field types
  3. # 1
Eric Accepted Answer Pending Moderation
Hi Julian & Patrick,

Thank you both for your quick anwser.

It's the output that needs the different format. The link Patrick provided is exactly what I was looking for. I should have looked better in the documentation.

[off topic] Is it an idea to create a section on this forum where F2C users can showcase their wildest, brilliant or wacky templates? Preferably a bit documented. I personally learn the most by just looking how other people solve their problems and it could turn out to be my favorite spot on this forum. [/off topic]

Rgds, Eric
  1. more than a month ago
  2. F2C field types
  3. # 2
ask me Accepted Answer Pending Moderation
Hi there

Thanks for this answer. I would like to go a step further: I would change format of the date that is shown while picking the date. Actually, the source is d-m-Y. But i want to change it to d.m.Y.

Is that possible? And, if yes, where can i do this?

Regards

brinkley
  1. more than a month ago
  2. F2C field types
  3. # 3
Julien Accepted Answer Pending Moderation
Hello Brinkley,

I figured it out for you, but the question was more difficult than I thought....

First add a new option to the file components/administrator/com_form2content/config.xml

Add the following line to the select box of the date format field:

[option value="%d.%m.%Y"]d.m.Y[/option]

(Please note that the square brackets above should be angled brackets)

Open the file components/com_form2content/js/f2c_frmval.js and edit the function F2C_ParseData

Change the expression
var regexDateFormat = new RegExp('^%([dmY])-%([dmY])-%([dmY])$');
into
var regexDateFormat = new RegExp('^%([dmY]).%([dmY]).%([dmY])$');

Open the file components/com_form2content/utils.form2content.com and edit the function ParseDate of the class F2cDateTimeHelper

Change these lines:

list($datePart, $timePart) = explode(' ', $date);

$dateFormat = explode('-', $format);
$dateParts = explode('-', $datePart);
$timeParts = explode(':', $timePart);

into this:

list($datePart, $timePart) = explode(' ', $date);

$strippedFormat = JString::str_ireplace('%d', '', $format);
$strippedFormat = JString::str_ireplace('%m', '', $strippedFormat);
$strippedFormat = JString::str_ireplace('%Y', '', $strippedFormat);
$separator = JString::substr($strippedFormat, 0, 1);
$dateFormat = explode($separator, $format);
$dateParts = explode($separator, $datePart);
$timeParts = explode(':', $timePart);

That should do the trick.....please back-up all the files before editing!

best,
Julien
  1. more than a month ago
  2. F2C field types
  3. # 4
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.