How to seperate day from acf datepicker

I have advanced custom field date picker form which I need to separate the day (monday,tuesday etc).Is this possible ,if yes anyone please tell me how?

  <p><strong>15-2-2014 Saturday</strong></p>

this is my html code

Related posts

Leave a Reply

3 comments

  1. Try this. If the date format is yymmdd, then the following works.

    $date = get_field('date');
    
    
    $y = substr($date, 0, 4); //Year
    $m = substr($date, 4, 2); //Month
    $d = substr($date, 6, 2); //date
    

    Find the ACF doc: ACF Datepicker

  2. $string  = "<p><strong>15-2-2014 Saturday</strong></p>";
    $string = explode(" ",preg_replace('~<[^>]+>~','',$string));
    $day = $string[1];
    

    edit:

    If you are using get_field() to get the date and it is in the format you showed, then it’s still a string. You’d do this:

    $string  = get_field('date');
    $string = explode(" ",preg_replace('~<[^>]+>~','',$string));
    $day = $string[1];
    

    the preg_replace may or may not be necessary depending on whether or not those html tags are really there, but it will work regardless. But if they aren’t there, then it can be simplified to

    $string  = get_field('date');
    $string = explode(" ",$string);
    $day = $string[1];