Extract WeakofYear on a form and save to another field

psyfer

New Member
Please I need help. Trying to save the weekofyear to another element in a FORM by

taking the selected date from the field 'entry_date_cal' and
update another field 'weakofyear_cal' with
the WeekNumber of the entered date.

I am using javascript - on the field 'entry_date_cal' on the 'select' event.
$('jos_timedata___weekofyear_cal').value =
date('W', (jos_timedata___entry_date_cal).getValue());

I have converted the date to a string and tried the strtotime function, but it still does not work. I can copy the entry_date element into the weakofyear element as date and just display the weekofyear, but I only need 2 digit weakofyear saved.

I have tried all sorts of variations to display/save the weekofyear number in a new field/element. This is for a timesheet and I want to order/group by weekofyear/date.

I am really stuck, perhaps it should not be javascript on event.
 
You can use a calc element
$date = date_create('{Your-date-element_raw}');
return date_format($date, 'W');
 
Back
Top