Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Mar 2008
    Location
    Leuchars, Scotland, UK
    Posts
    51
    Thanks
    19
    Thanked 0 Times in 0 Posts

    date: change "03" into "March"

    just a quicky,

    If tried a number of ways to turn "03" into "March" & "04" into "april" and so on.........
    PHP Code:
    $date ="03";
    $date strftime("%b"$date); 
    I'm obviously using the wrong command but I'm balls'd if I can find the right one.


    Help 4 a thicky???

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Trinity-Links View Post
    just a quicky,

    If tried a number of ways to turn "03" into "March" & "04" into "april" and so on.........
    PHP Code:
    $date ="03";
    $date strftime("%b"$date); 
    I'm obviously using the wrong command but I'm balls'd if I can find the right one.


    Help 4 a thicky???
    if you don't need to work with date, this will work:
    PHP Code:
    $months = array("January""February""March""April""May""June""July""August""September""October""November""December");
    $thismonth 3;
    echo 
    $months[$thismonth-1]; 
    best regards

  • Users who have thanked oesxyl for this post:

    Trinity-Links (03-11-2009)

  • #3
    Regular Coder Iszak's Avatar
    Join Date
    Jun 2007
    Location
    Perth, Western Australia
    Posts
    332
    Thanks
    2
    Thanked 58 Times in 57 Posts
    PHP Code:
    <?php
    $month 
    03;

    echo 
    date('F'mktime(000$month 101970)); // March
    // OR
    echo strftime('%B'mktime(000$month 101970)); // March
    Don't know why I need to +1, but I do!

    Edit: I like this way,
    PHP Code:
    echo strftime('%B'strtotime("$month/1/1970")); 
    Last edited by Iszak; 03-10-2009 at 01:29 AM.

  • Users who have thanked Iszak for this post:

    Trinity-Links (03-11-2009)

  • #4
    New Coder
    Join Date
    Mar 2009
    Posts
    52
    Thanks
    4
    Thanked 6 Times in 6 Posts
    You need $month+1 because you set day = 0. Set day=1 and problem solved. Hence why you don't need the $month+1 in your third example.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •