I have a server app which is sent a date in the local format of the client
machine. I've no control over the client app at all, so have to code at the
server end to cope with any problems. The server is in the US, so any
dates need to be in US format before they will convert using strtotime()
Here is what i'm doing at the moment..
// need to convert date to use USA mm/dd/yyyy format on server
$split = explode(",",$_S ERVER[HTTP_ACCEPT_LAN GUAGE]);
switch ($split[0]) {
case "en-us":
break;
case "en-gb":
$lt = substr($lt,3,3) . substr($lt,0,3) . substr($lt,6);
break;
case "da":
case "pt":
$lt = substr($lt,3,2) . "/" . substr($lt,0,2) . "/" . substr($lt,6);
break;
}
$ustime = strtotime($lt);
As you can see, the switch could get huge.. Is there any easier way ?
Thanks
Adrian
machine. I've no control over the client app at all, so have to code at the
server end to cope with any problems. The server is in the US, so any
dates need to be in US format before they will convert using strtotime()
Here is what i'm doing at the moment..
// need to convert date to use USA mm/dd/yyyy format on server
$split = explode(",",$_S ERVER[HTTP_ACCEPT_LAN GUAGE]);
switch ($split[0]) {
case "en-us":
break;
case "en-gb":
$lt = substr($lt,3,3) . substr($lt,0,3) . substr($lt,6);
break;
case "da":
case "pt":
$lt = substr($lt,3,2) . "/" . substr($lt,0,2) . "/" . substr($lt,6);
break;
}
$ustime = strtotime($lt);
As you can see, the switch could get huge.. Is there any easier way ?
Thanks
Adrian
Comment