TOPIC:

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

  • Topic Author
  • JayZed
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 7
  • 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" 3 weeks 17 hours ago #276258

  • Mirec's Avatar
  • Mirec
  • Offline
  • Ultimate Breezer
  • Ultimate Breezer
  • Posts: 2967
  • Karma: 2
  • Thanks: 150
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" 3 weeks 15 hours ago #276264

  • Topic Author
  • JayZed
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 7
  • 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" 3 weeks 15 hours ago #276269

  • Mirec's Avatar
  • Mirec
  • Offline
  • Ultimate Breezer
  • Ultimate Breezer
  • Posts: 2967
  • Karma: 2
  • Thanks: 150
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.048 seconds

BreezingForms Pro 1.4.7 for WordPress Released!

Available in the membership section.

September Discount!

Massive discounts on all subscriptions!

Get Your Subscription Here

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

Special Offer

Summer 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!