Php changing date format

Posted on 2011-10-07
Last Modified: 2012-05-12
Hi Experts,

I need to convert the date formatted like this:
Friday 28 October 2011

Many Thanks
Question by:maccaj51
    LVL 107

    Expert Comment

    by:Ray Paseur
    LVL 107

    Expert Comment

    by:Ray Paseur
    Date("Y-m-d") is probably what you want, or date('c')
    LVL 4

    Accepted Solution


    This is a bit of a shot in the dark as I don't have access to test the code at the moment but you could try using the strtotime function that converts a string date/time into unix timestamp, then put this through date() to format it, something similar to:

    echo date('Y-m-d', strtotime('Friday 28 October 2011'));

    Open in new window

    More info here:

    strtotime -
    date -

    Hope this helps,


    LVL 107

    Expert Comment

    by:Ray Paseur
    This works.  You might want to use date_default_timezone_set() depending on where your clients and servers are located.

    Best regards, ~Ray
    <?php // RAY_temp_maccaj.php
    $in = 'Friday 28 October 2011';
    echo date('Y-m-d', strtotime($in));

    Open in new window


    Author Closing Comment

    Thanks Guys... Sorry Ray I just used the first one... Thank you for your response though

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
    Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now