Q:

twig automatic convert string to day

I want to convert a string value to day by tapping in a widget, e.g.  24 → 1
{% block convert_day %}
    <td>{{ form_widget(form['crush']) }}</td>
    <td><!-- displaying my value in day --></td>
{% endblock %}

No It doesn't work !
To be more clear ,I want to do something like that but just display number of days : http://www.convertworld.com/en/time/Days.html

A:

that's what I did ; 
<script type="text/javascript">

function execute_time_ext(clicked) {
if (document.forms && document.forms['show_convert']) {
var from = document.forms['show_convert'].unit_from.value;
var elms = document.getElementsByName('unit');
var amount = document.forms['show_convert']['value'].value;
var to;
var amount_int = ['show_convert']['value'] - 0;
for (var i=0; i<elms.length; i++) {
to = elms[i].value;
convert(show_convert['value'], from, to, false, false);
}
var cookie = 'default_decimals';
if (getCookie(cookie) != decimals) {
setCookie(cookie, decimals, null, '/');
}
} else {
if (clicked) {
alert('Converter error. Conversion not supported by browser.');
}
}
}
execute_time_ext(false);

</script>

widget :
<div onkeyup="execute_time_ext(true)" onchange="execute_time_ext(true)"> {{ form_widget(form['value']) }} {% endblock %}

                                <div> <input id="value_4" type="hidden" value="365.25|0|4" name="unit"></div>
                        </div>

