topical media & game development

talk show tell print

basic-regex-23-SplitDate.php / php



  <html>
  <head>
  <title>Splitting a date using ereg()</title>
  </head>
  <body>
  <?php
  myPattern = '([12][0-9]{3}) ([01][0-9]) ([0123][0-9])';
  testString = gmdate("Y m d");
  echo "<p>The date is now: testString</p>";
  myResult = ereg(myPattern, testString, matches);
  if (myResult)
  {
  echo "<p>A match was found when testing case sensitively.</p>";
  echo "<p>Expressed in MM/DD/YYYY format the date is now, matches[2]/matches[3]/matches[1].</p>";
  } 
  else
  {
  echo "<p>No match was found when testing case sensitively.</p>";
  }
  ?>
  </body>
  </html>


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.