SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    John 8:24 JREAM's Avatar
    Join Date
    Sep 2007
    Location
    Florida
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    if (empty(DATETIME)) ?

    If you fetch a MySQL DATETIME that's not set,

    Output: 0000-00-00 00:00:00

    if (empty($date)) { echo 1; }
    if (!isset($date)) { echo 2; }

    How do I check if the Date isn't a real date?

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

  3. #3
    John 8:24 JREAM's Avatar
    Join Date
    Sep 2007
    Location
    Florida
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey, Thanks man ! Sorry for my delayed message I was installing Apache

  4. #4
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use some method instead:
    PHP Code:
    function formatDate($format,$dateStr) {
      if (
    trim($dateStr) == '' || substr($dateStr,0,10) == '0000-00-00') {
        return 
    '';
      }
      
    $ts strtotime($dateStr);
      if (
    $ts === false) {
        return 
    '';
      }
      return 
    date($format,$ts);


  5. #5
    SitePoint Evangelist stonedeft's Avatar
    Join Date
    Aug 2009
    Posts
    586
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by PHPycho View Post
    Use some method instead:
    PHP Code:
    function formatDate($format,$dateStr) {
      if (
    trim($dateStr) == '' || substr($dateStr,0,10) == '0000-00-00') {
        return 
    '';
      }
      
    $ts strtotime($dateStr);
      if (
    $ts === false) {
        return 
    '';
      }
      return 
    date($format,$ts);

    nice function this one goes in my function archives thnx man you look good !
    Don't Panic

  6. #6
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Er, that's the function in the first comment from the manual entry for strtotime (in my first post). So unless that comment in the manual was PHPycho's, then no, he doesn't "look good".

  7. #7
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Raffles View Post
    Er, that's the function in the first comment from the manual entry for strtotime (in my first post). So unless that comment in the manual was PHPycho's, then no, he doesn't "look good".
    concept matters.
    Just take the good concepts.


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
  •