Results 1 to 2 of 2

Thread: help w/date

  1. #1
    Join Date
    Apr 2013
    gastonia NC

    help w/date

    hi, I want to replace the date with "0000-00-00" to " ". the code below replaces field regardless
    of value. please advise. thanks
    PHP Code:
    if (str_replace(array('0','-',':'),"000-00-00 00:00") == ''

  2. #2
    Join Date
    Aug 2004
    Well, the str_replace() in your code will never work since you only give it 2 args, and it requires at least 3. However, putting that aside for the moment, it's not 100% clear to me what you are really trying to do, but I think maybe what you want is:
    PHP Code:
    $row['duedate'] = preg_replace('/^[0:-]*$/'''$row['duedate']); 

    What that does (unless I screwed up something): if $row['duedate'] only contains zeroes, colons, and/or hyphens (or is empty), then it is changed to an empty string.
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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