TOPIC:

day of year 8 months 3 weeks ago #275356

  • Topic Author
  • JayZed
  • Offline
  • New Member
  • New Member
  • Registered
  • Posts: 8
  • Thanks: 0
Searched - but not found.
How to get the number of the actual day, like "dayofyear"?
I want to know if the actual day is after 31.03. (day 91) and before 01.10. (day 274).
Leap Year doesnt matter :-).
Hope you can help me.
Greetings - jurgen

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

Last edit: Post by JayZed.

day of year 8 months 3 weeks ago #275369

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Registered
  • Posts: 12079
  • Thanks: 780
Hi,

I have a question:

are you using standard calendar and then when you select date in calendar your want to print "somewhere" current day number?

UPDATE: I found a solution

1) add two textfields (one for calendar and one form number of day of the year)

2) go to form->Advanced->More options->Form pieces->Before form->Check Custom and put:
JFactory::getDocument()->addStyleSheet('https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css');
JFactory::getDocument()->addScript('https://code.jquery.com/jquery-1.12.4.js');
JFactory::getDocument()->addScript('https://code.jquery.com/ui/1.12.1/jquery-ui.min.js');


JFactory::getDocument()->addScriptDeclaration('
    $(document).ready(function() {
        $("#ff_elem8574").datepicker({dateFormat: "yy-mm-dd",
 minDate: 0,
    });
});
');
-please replace #ff_elem8574 with ID of textfield which is for calendar
To find ID do the right click to browser and in Console find ID for this element

When you click on this textfield you will see calendar

3) go to form->Advanced->More options->Scripts->Initialization script->check Custom and put:
function ff_formname_init()
{
setInterval('calc()', 500);
} // ff_formname_init

function calc() {
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;
}
Please replace:
-formname with name of your form (not title)
-nameoftextfieldforcalendar with name of textfield for calendar (not title)
-nameoftextfieldforcountdayofyear with name of textfield for cound day of year (not title)

Basically, this works on way when you select some day in calendar in other textfield you will see number of day of the year

If you get in stuck let me know, and I will help
Regards,
Tihana

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

Last edit: Post by tihana.krivic.

day of year 7 months 3 weeks ago #276220

  • Topic Author
  • JayZed
  • Offline
  • New Member
  • New Member
  • Registered
  • Posts: 8
  • Thanks: 0
Thanks Tihana - it seems to complicated for me, maybe u know how to find a smart code.

BreezingForms 1.9.1 Stable (build 941)

I need a code to find out if it is winter or summer as descriped.

I have an unused database-Field, if needed:
einnahmen_dusche varchar(6) utf8_general_ci Ja NULL

Neither I know where to put the code nor I have any idea to integrate this.

The decision summer/winter has to been defined after the client enter a date in a fomular.

After input field "Anreise" (anreise varchar(10) utf8_general_ci, type date) I can put a code in fieldoptions to define "summer" (maybe field einnahmen_dusche).

Then I have different fields which need to "know" if it is summer or winter. Because we have different cost in our hut on summer or winter. Winter we need more heating and warm water :-).

Actually our code:

var betrag = (5.00 * value * bfField ('anzahl_naechte'));
value = betrag.toFixed(2);
ff_getElementByName("gebuehren_em").value = value;


Our "wished" code:


//summer is between 1. april and 30. september

if <summer>
var betrag = (5.00 * value * bfField ('anzahl_naechte'));
else
var betrag = (6.00 * value * bfField ('anzahl_naechte'));


Maybe we check on-the-fly the field anreise for every needed field if it is summer or winter?

heartly greetings :-)

jurgen

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

day of year 7 months 3 weeks ago #276223

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Registered
  • Posts: 12079
  • Thanks: 780
Hi,

this is "smart" code, it is not too complicated, if you want I can create an example on your page, but then I need your backend link and login information

Use this tag:
[confidential]
[/confidential]
I will integrate it for you in a small example that you can check how it works :)

About summer, winter, I need to test this, and let you know, please give me some time :)

Regards,
Tihana

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

day of year 7 months 3 weeks ago #276224

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

Your smartCode was great!

I dive deeper in java and find a java online-testconsole.

The rest has been try an error.

Here the final code for the numerous day of year:

const now = new Date();
// anreise is my database-field when someone visit the first day our little hut
var heute=new Date(ff_getElementByName('anreise').value);
var starttag=new Date(now.getFullYear(), 0, 0);
var diff = now - starttag;
var oneDay = 1000 * 60 * 60 * 24;
var day = Math.floor(diff / oneDay);

// stored in my field
ff_getElementByName('DayOfYear').value=day;

Thank you very very much. Great help!!!

jurgen

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

Last edit: Post by JayZed. Reason: Solution

day of year 7 months 3 weeks ago #276226

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

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

Last edit: Post by JayZed.
  • Page:
  • 1
  • 2
Time to create page: 0.058 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!