Re: [PHP] From 24/7/2013 to 2013-07-24

[email protected] (jomali)
Newsgroups php.general
Message-ID <CAKh53Ys-jukRBBt8PjAXHZv_wL2-XgMpNPkrNOnJNP7qCtvn_g@mail.gmail.com>
On Fri, Jul 26, 2013 at 5:18 AM, Karl-Arne Gjersøyen <[email protected]>wrote:

> Below is something I try that ofcourse not work because of rsosort.
> Here is my code:
> -----------------------
> $lagret_dato = $_POST['lagret_dato'];
>     foreach($lagret_dato as $dag){
>
>         $dag = explode("/", $dag);
>        rsort($dag);
>         $dag = implode("-", $dag);
>         var_dump($dag);
>
> What I want is a way to rewrite contents of a variable like this:
>
> From 24/7/2013 to 2013-07-24
>
> Is there a way in PHP to do this?
>
> Thank you very much.
>
> Karl
>

$conv_date = str_replace('/', '-','24/7/2013');
echo date('Y-m-d', strtotime($conv_date));
Result: 2013-07-24
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.