Thursday, June 9, 2011


<script type="text/javascript">
function checkSearch()
{
if(!document.getElementById || !document.createTextNode){return;}

if(!document.getElementById('search')){return;}
var searchValue=document.getElementById('search').value;
if(searchValue=="")
{
alert("Please enter a search term before sending the form");
return false;
}
else if(searchValue=='JavaScript')
{
var really=confirm('"JavaScript" is a very common term. \n' + 'Do you really want to search for this?');
return really;
}
else
{
return true;
}

}
</script>



This is a php tutorial on dates


<?php
$mydates = array("now", "today", "tomorrow", "yesterday", "Thursday", "this Thursday", "last Thursday", "+2 hours", "-1 month", "+10 minutes", "30 seconds", "+2 years -1 month", "next week", 'last month", "last year', "2 weeks ago"
);
echo "<table>";
//remeber: strtotime() returns a timestamp
foreach($mydates as $mydate)
{
echo '<tr><td>' . $mydate .':' . date('r', strtotime($mydate)) . "</td></tr>\n";
}
echo "</table>";


?>




<?php
echo "Today is " . date('d M Y') . '. ';
for($i = 1; $i <= 12; $i++){
$nextmonth = date('Y-' . (date('n')+$i) . '-01');
$nextmonth_ts = strtotime($nextmonth);
$firsttue_ts = strtotime("Tuesday", $nextmonth_ts);

echo '\n
The first Tuesday in ' . date('F', $firsttue_ts) . ' is ' . date('d M Y', $firsttue_ts) . '. ';
}
?>


No comments: