mktime() Error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Limno
    New Member
    • Apr 2008
    • 92

    mktime() Error

    hi All,

    echo date("l",mktime (1,0,0,$d[1],$d[2],$d[0]));

    its printing "Sunday, 4th January, 2010" but its monday

    Can anyone correct this...

    Thanks in advance..
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    there’s probably something wrong with your input. a hardcoded test did output the correct day of the week.

    Code:
    echo date("r", mktime(1,0,0,1,4,2010));
    // Mon, 04 Jan 2010 01:00:00 +0100
    besides date("l") only returns the weekday, not the whole date.

    Comment

    • Limno
      New Member
      • Apr 2008
      • 92

      #3
      Still its not working, i am inserting data on one date and i need to display the posted date and its day. Need some suggestion..

      Thanks

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        var_dump($d); (to see, whether you pass the right values)

        Comment

        • Limno
          New Member
          • Apr 2008
          • 92

          #5
          array(1) { [0]=> string(17) "5th January, 2010" }

          its showing this...

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            so you’re missing $d[1] and $d[2] …

            Comment

            • Markus
              Recognized Expert Expert
              • Jun 2007
              • 6092

              #7
              Where is the array $d being populated?

              Comment

              • Limno
                New Member
                • Apr 2008
                • 92

                #8
                $d = explode('-', $row['date']);

                var_dump($d[2]);
                echo date("l",mktime (0,0,0,$d[1],$d[2],$d[0]));
                My code is this, or tell me how to display my date in this format

                [Monday, 4th January, 2010]

                Thanks.

                Comment

                • Dormilich
                  Recognized Expert Expert
                  • Aug 2008
                  • 8694

                  #9
                  what about
                  Code:
                  strtotime($row["date"]);
                  ?

                  a list of output options is listed at the date() manual.

                  Comment

                  • Limno
                    New Member
                    • Apr 2008
                    • 92

                    #10
                    Thank you Dormilich, its working

                    Comment

                    Working...