Welcome Guest, Not a member yet? Register   Sign In
date('Y-m-d') don't work !!! [resolved]
#4

[eluser]krislec[/eluser]
the view:

Code:
...
<td>
  &lt;?php if(isset($r->date_age) AND $r->date_age!= "0000-00-00" ): echo date('d/m/Y',strtotime($r->date_age));endif; ?&gt;
</td>

the controller:
Code:
...
$this->form_validation->set_rules('date_age','Date de naissance','trim|required|xss_clean');

    if ($this->form_validation->run())
              {
                  $data = array (
                      ...
                      'date_age' => date('Y-m-d',strtotime($this->input->post('date_age'))),
                      ...

I need to put date('m/d/Y') to have a real date with this format d/m/Y (for the screen)...???


I have made little test function but i don't how I can make it in use in the set->rules line.

Code:
/* Date au format 0000-00-00 */

function toDateMysql($date){
        if (preg_match("#(\d{2})-(\d{2})-(\d{4})#",$date)) {
                return preg_replace("#(\d{2})-(\d{2})-(\d{4})#","$3-$2-$1", $date);
        } else {
                return false;
        }
}

/* Date au format 00/00/0000 */

function toDateFr($date){
        if (preg_match("#(\d{4})-(\d{2})-(\d{2})#",$date)) {
                return preg_replace("#(\d{4})-(\d{2})-(\d{2})#","$3-$2-$1", $date);
        } else {
                return false;
        }

Thanks for helping me.


Messages In This Thread
date('Y-m-d') don't work !!! [resolved] - by El Forum - 05-04-2011, 02:57 AM
date('Y-m-d') don't work !!! [resolved] - by El Forum - 05-04-2011, 04:02 AM
date('Y-m-d') don't work !!! [resolved] - by El Forum - 05-04-2011, 04:02 AM
date('Y-m-d') don't work !!! [resolved] - by El Forum - 05-04-2011, 05:00 AM
date('Y-m-d') don't work !!! [resolved] - by El Forum - 05-04-2011, 05:35 AM
date('Y-m-d') don't work !!! [resolved] - by El Forum - 05-04-2011, 06:26 AM
date('Y-m-d') don't work !!! [resolved] - by El Forum - 05-04-2011, 07:11 AM
date('Y-m-d') don't work !!! [resolved] - by El Forum - 05-04-2011, 07:41 AM
date('Y-m-d') don't work !!! [resolved] - by El Forum - 05-04-2011, 10:13 AM



Theme © iAndrew 2016 - Forum software by © MyBB