www.webdeveloper.com
Results 1 to 2 of 2

Thread: help w/date

  1. #1
    Join Date
    Apr 2013
    Posts
    61

    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") == ''
    {
    $row['duedate']='';} 

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,176
    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.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

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



Recent Articles