SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2011
    Posts
    57
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Catching only month from the full date from mysql in php

    Dear All

    I have DB with some field such as "orderno", "orderqty" & "deliverydate".

    My deliverydate store in mysql table as yyyy-mm-dd, now i want to catch only month from the deliverydate, like if its 2011-04-23 then it will count as April month & for 2011-05-30 will show May & so on.

    Is it possible to do it in php?

    I want to do it to find out the total order quantity for each month. Need your kind help.

  2. #2
    SitePoint Zealot Zurev's Avatar
    Join Date
    Feb 2009
    Posts
    171
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $deliveryDate "1954-09-15"// September 15th, 1954
    $deliveryDate strtotime($deliveryDate); // Integer timestamp of the date

    $dateMonth getdate($deliverydate);
    echo 
    $dateMonth["month"]; // September 

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2011
    Posts
    57
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your help.

    Its showing the month as January, but it s/b show September.


Bookmarks

Posting Permissions

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