Date in custom format

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • phpmagesh
    New Member
    • Nov 2008
    • 119

    Date in custom format

    Hi,

    I have to show system date in custom format

    For example: 2009/Oct/06

    I want to show date in above format. how to get this output .

    i used the below format
    Code:
    $months = array(1 => "Jan", 2 => "Feb", 3 => "Mar", 4 => "Apr", 5 => "May", 6 => "Jun", 7 => "Jul", 8 => "Aug", 9 => "Sep", 10 => "Oct", 11 => "Nov", 12 => "Dec");
    
    $raw_date = date("Y/m/d");
    list($year, $month, $day) = split('[/]', $raw_date);		
    $date = $year . "/" . $month . "/" . $day;
    But i struck how to apply that array format in this format?

    Can any one help me how to get the custom format date using php.

    Thanks in advance

    Regards,
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    what about
    Code:
    date("Y/M/d")
    ?

    Comment

    • phpmagesh
      New Member
      • Nov 2008
      • 119

      #3
      Originally posted by Dormilich
      what about
      Code:
      date("Y/M/d")
      ?
      in date("Y/M/d") function i am getting output as 2009/10/06.

      but i want date in 2009/Oct/06. this format.

      How to get this?

      thanks in advance

      Regards,

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        Originally posted by phpmagesh
        in date("Y/M/d") function i am getting output as 2009/10/06.
        you probably wrote "Y/m/d" since "Y/M/d" resulted in the desired output (I tested that!)
        Attached Files

        Comment

        • Dormilich
          Recognized Expert Expert
          • Aug 2008
          • 8694

          #5
          Originally posted by cestapassu
          is there any difference between M and m? Is it case sensitive?
          well, obviously. haven’t you looked at date()’s formatting options? (that’s about three dozen letters)

          Comment

          Working...