Problem on date: 1919/1010/2018181818 03:15:16 PM

-2

It's all right but when it comes to displaying or saving the date on the database, it's getting like this 1919/1010/2018181818 03:15:16 PM ... I do not know what problem, or if I messed up somewhere. Does anyone know why this is ?? you can see that the time is right but that's only the date.

Settings page (php):

(index)

$this->form_validation->set_rules('dateformat', lang('date_format'), 'required');
$this->form_validation->set_rules('timeformat', lang('time_format'), 'required');

($ data)

'dateformat' => DEMO ? 'jS F Y' : $this->input->post('dateformat'),
                'timeformat' => DEMO ? 'h:i A' : $this->input->post('timeformat'),

footer page:

<script type="text/javascript">

    var base_url = '<?=base_url();?>';

    var dateformat = '<?=$Settings->dateformat;?>', timeformat = '<?= $Settings->timeformat ?>';

    <?php unset($Settings->protocol, $Settings->smtp_host, $Settings->smtp_user, $Settings->smtp_pass, $Settings->smtp_port, $Settings->smtp_crypto, $Settings->mailpath, $Settings->timezone, $Settings->setting_id, $Settings->default_email, $Settings->version, $Settings->stripe, $Settings->stripe_secret_key, $Settings->stripe_publishable_key); ?>

    var Settings = <?= json_encode($Settings); ?>;
    $(window).load(function () {
        $('.mm_<?=$m?>').addClass('active');
        $('#<?=$m?>_<?=$v?>').addClass('active');
    });

</script>

All.js Page:

 $('.clock').click( function(e){
        e.preventDefault();
        return false;
    });
    function Now() { return new Date().getTime(); }
    var stamp = Math.floor(Now() / 1000);
    var time = date(dateformat+' '+timeformat, stamp);
    $('.clock').text(time);

    window.setInterval(function(){
        var stamp = Math.floor(Now() / 1000);
        var time = date(dateformat+' '+timeformat, stamp);
        $('.clock').text(time);
    }, 10000);

Page header:

<li class="hidden-xs hidden-sm"><a href="#" class="clock"></a></li>
    
asked by anonymous 19.10.2018 / 20:16

2 answers

1

Good afternoon, I think that at the time of viewing you should be using something like dd/mm/Yyyy H:i:s but in php formatting the date does not require more than one letter to identify which part of the date it will be printed, try something like d/m/Y H:i:s to format it

    
19.10.2018 / 20:28
0

Try something similar to this example to work with dates.

// Definindo dados de teste aqui ou mandado via formulário.
$_POST["Data"] = "19/10/2018 16:30";
// Define a sua zona geografica.
date_default_timezone_set("America/Sao_Paulo");
// Gerar objeto DateTime.
$oData = new DateTime();
// Define a data para o objeto DateTime.
$_POST["Data"] = str_replace("/", "-", $_POST["Data"]);
$oData->setTimestamp(strtotime($_POST["Data"]));
// Mostra os dados
print($oData->format("d/m/Y H:i:s"));
    
19.10.2018 / 20:46