SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: mktime()

  1. #1
    SitePoint Evangelist
    Join Date
    Jun 2010
    Posts
    453
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    mktime()

    Why does mktime() throw a notice when it acts on a variable?

    Here's the notice I get: Notice: A non well formed numeric value encountered in E:\wamp\www\test_120319.php on line 21. Please notice line 22 doesn't produce a notice.
    PHP Code:
    line20:   $temp "28,41,20,19,03,2012";
    line21:   echo mktime($temp) . '<br />';
    line22:   mktime(28,41,20,19,03,2012) . '<br />'

  2. #2
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Because that is not how it works. It doesn't take a string like that.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  3. #3
    SitePoint Evangelist
    Join Date
    Jun 2010
    Posts
    453
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Then whats the difference between line 20 and 22?

  4. #4
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Its not obvious? Line 20 is a string. Line 22 is a function with arguments. You cannot take the arguments on Line 22 and put them into a string and expect it to work.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  5. #5
    SitePoint Evangelist
    Join Date
    Jun 2010
    Posts
    453
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    No, it wasn't, but I knew I should know better when I sent my last post.

    This was what I needed to see: mktime($sec,$min,$hr,$day,$mo,$year).

    Thanks for making me think logic_earth.


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
  •