TOPIC:

Calc DaysOfYear - transform Date-Type "dd.MM.yyyy" 7 months 3 weeks ago #276251

  • Topic Author
  • JayZed
  • Offline
  • New Member
  • New Member
  • Registered
  • Posts: 8
  • Thanks: 0
Hi,

another little problem.

I need to compare to different date-types.

Tihana (now in vacation) has been so cute to make me this code as a gift:

function calcDaysOfYear() {
var now=new Date(ff_getElementByName('nameoftextfieldforcalendar').value);
var start=new Date(now.getFullYear(), 0, 0);
var diff = now - start;
var oneDay = 1000 * 60 * 60 * 24;
var day = Math.floor(diff / oneDay);
ff_getElementByName('nameoftextfieldforcountdayofyear').value=day;
}

It works fine. But for variable "now" I need to transform my stored date (in the format "dd.MM.yyyy", no textfieldforcalendar) to a date-format like "newDate()".

Tried a lot of code in forums but didnt succeed. "SimpleDateFormat" doesnt work.

Hope for another smart code or help :-)


Best regards jurgen

Please Log in or Create an account to join the conversation.

Last edit: Post by JayZed.

Calc DaysOfYear - transform Date-Type "dd.MM.yyyy" 7 months 3 weeks ago #276258

  • Mirec's Avatar
  • Mirec
  • Offline
  • Platinum Member
  • Platinum Member
  • Registered
  • Posts: 3262
  • Thanks: 163
Hi,

I will help you, could you please send me the backend link and access data by email ma@evolutio.hr please write the name of the FORM, too, so I can see logic of the function.

Let me know!

Regards,
Mirko

Please Log in or Create an account to join the conversation.

Calc DaysOfYear - transform Date-Type "dd.MM.yyyy" 7 months 3 weeks ago #276264

  • Topic Author
  • JayZed
  • Offline
  • New Member
  • New Member
  • Registered
  • Posts: 8
  • Thanks: 0
Hi Mirko,

thanks for replying.

I coded a solution.
Just looking for a oneliner to convert a string "dd.MM.yyyy".

Actually I did it with:

//Anreisedatum in Datumsformat wandeln
var zanreise=ff_getElementByName('anreise').value;
xanreise=(zanreise.substr(6,4)+"/"+zanreise.substr(3,2)+"/"+zanreise.substr(0,2));
xanreise=xanreise+" 0:0:1 GMT+0200";

const now = new Date(xanreise);
var anreisetag = now;
var jahresersttag=new Date(now.getFullYear(), 0, 0);
var diff = anreisetag - jahresersttag;
var oneDay = 1000 * 60 * 60 * 24;
var day = Math.floor(diff / oneDay);
ff_getElementByName('einnahmen_dusche').value=day;

}

No access or sourcecode to our site needed :-)

Thanks. Regards. jurgen

Please Log in or Create an account to join the conversation.

Calc DaysOfYear - transform Date-Type "dd.MM.yyyy" 7 months 3 weeks ago #276269

  • Mirec's Avatar
  • Mirec
  • Offline
  • Platinum Member
  • Platinum Member
  • Registered
  • Posts: 3262
  • Thanks: 163
Hi,

super, I'm glad you find a solution!


If you have more questions, feel free to ask!


Regards,
Mirko

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.050 seconds

Support Chat

Join our Discord chat and enter the Crosstec channels for live-support, chat forums and interact directly with the community!

After joining, please enter the Crosstec Area and use the #crosstec-support or #crosstec-general channels.

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Subscribe to news and updates!

Special Offer

Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!

Live Support Chat Opened!

Join our Discord chat here and enter the Crosstec channels to receive live support and talk directly to the team!