calin-beard
11/13/2017 - 4:14 PM

Add current date in hidden field.

Add current date in hidden field.

<!--START code current date to hidden field-->
<!--format DD/MM/YYY-->
<script>
$(document).ready(function () {       
        var getDate = function () {
            var dateObject = new Date(),
                disp = [];

            disp.push(dateObject.getDate().toString());
            
            if(dateObject.getMonth() < 9) {
                disp.push( '0' + (dateObject.getMonth() + 1).toString() );
            } else {
                disp.push( (dateObject.getMonth() + 1).toString() );
            }
            
            disp.push(dateObject.getFullYear().toString());
            
            return disp.join( '/' );
        }; //getDate()

          $( 'input[name="'+ window.btoa( 'date' ) +'"]').attr("value", getDate() );         
           
}); // ready
</script>
<!--END code current date to hidden field-->
<!--START code current date to hidden field-->
<script>
$(document).ready(function () {       
        var date = function () {
            var dateObject = new Date();
            var disp = [];
            var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];

            disp.push(monthNames[dateObject.getMonth()]);
            disp.push(dateObject.getDate());
            disp.push(dateObject.getFullYear());
            
            return disp.join( ' ' );
        }; //function

          $( 'input[name="'+ base64_encode( 'date' ) +'"]').attr("value", date() );         
           
}); // ready
</script>
<!--END code current date to hidden field-->