datum-convert-amerikaanseuropees
Gesponsorde koppelingen
PHP script bestanden
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
public function convertDate($DATE){
if(eregi('/',$DATE)){
$_DATE = explode("/", $DATE);;
} else if(eregi('-',$DATE)){
$_DATE = explode("-", $DATE);
}
// als eerste element gelijk aan 4, datum is in yyyy-mm-dd format
if(strlen($_DATE[0]) == 4){
$_DATE[2] = (strlen($_DATE[2]) == 1) ? '0'.$_DATE[2] : $_DATE[2];
$_DATE[1] = (strlen($_DATE[1]) == 1) ? '0'.$_DATE[1] : $_DATE[1];
$return = $_DATE[0] .'-'. $_DATE[1] .'-'. $_DATE[2];
}else{
$_DATE[0] = (strlen($_DATE[0]) == 1) ? '0'.$_DATE[0] : $_DATE[0];
$_DATE[1] = (strlen($_DATE[1]) == 1) ? '0'.$_DATE[1] : $_DATE[1];
$return = $_DATE[2] .'-'. $_DATE[1] .'-'. $_DATE[0];
}
if(!eregi("^[0-9]{4}[-]?[0-9]{2}[-]?[0-9]{2}$", $return))
return "Bad date";
else
return $return;
}
?>
public function convertDate($DATE){
if(eregi('/',$DATE)){
$_DATE = explode("/", $DATE);;
} else if(eregi('-',$DATE)){
$_DATE = explode("-", $DATE);
}
// als eerste element gelijk aan 4, datum is in yyyy-mm-dd format
if(strlen($_DATE[0]) == 4){
$_DATE[2] = (strlen($_DATE[2]) == 1) ? '0'.$_DATE[2] : $_DATE[2];
$_DATE[1] = (strlen($_DATE[1]) == 1) ? '0'.$_DATE[1] : $_DATE[1];
$return = $_DATE[0] .'-'. $_DATE[1] .'-'. $_DATE[2];
}else{
$_DATE[0] = (strlen($_DATE[0]) == 1) ? '0'.$_DATE[0] : $_DATE[0];
$_DATE[1] = (strlen($_DATE[1]) == 1) ? '0'.$_DATE[1] : $_DATE[1];
$return = $_DATE[2] .'-'. $_DATE[1] .'-'. $_DATE[0];
}
if(!eregi("^[0-9]{4}[-]?[0-9]{2}[-]?[0-9]{2}$", $return))
return "Bad date";
else
return $return;
}
?>