Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

datefield with current date value

datefield with current value date

Set a datefield with the value of the current system date using phtml

<div class="row">
        <div class="large-2 columns">
            <label for="fieldContFecnaci">FECHA DE NACIMIENTO</label>
        </div>
        <div class="large-4 columns">
            <?php
echo $this->tag->dateField(array("CONT_FECNACI",  "id" => "fieldContFecnaci")) ?>
        </div>
<div class="large-2 columns">
            <label for="fieldContFecinsc">FECHA DE INSCRIPCION</label>
        </div>
        <div class="large-4 columns">
            <?php echo $this->tag->dateField(array("CONT_FECINSC", "id" => "fieldContFecinsc")) ?>
        </div>
    </div>

I previously used javascript. How would you do in Phalcon?

<script type="text/javascript">
    $(document).on('ready', function () {
    var now = new Date();
    var month = (now.getMonth() + 1);
    var day = now.getDate();
    if (month < 10)
        month = "0" + month;
    if (day < 10)
        day = "0" + day;
    var today = now.getFullYear() + '-' + month + '-' + day;
    $('#fieldContFecnaci').val(today);
    $('#fieldContFecinsc').val(today);
});

</script>

I can not use the function now gives me an error



30.7k
Accepted
answer

<?php echo $this->tag->dateField(array("CONT_FECINSC", "id" => "fieldContFecinsc", "value" => date("Y-m-d"))) ?>



33.9k

You help change the format to send to the database as need you to go as dd / mm / yyyy