Home   Best Sellers   Blogging   Coding & Design   Technology   SEO   Travel & living   Career   Videos   Tips   Calculators     
Home  »     »     »  PHP Function to return upper and lower time stamp of a given date

PHP Function to return upper and lower time stamp of a given date

Monday, November 29, 2010



Function to return upper and lower time stamp of a given date

Function returns the upper and lower time stamp of a given date in dd/mm/yyyy format.

checks date in dd/mm/yyy format is valid and return upper/lower limit of timestamp of that day as integer

if date is invalid then returns 0 // $upper_or_lower = U or L

if date is null this will return current time stamp






function getTimeStamp($Date="",$upper_or_lower="l"){
//checks date in dd/mm/yyy format is valid and return upper/lower limit of timestamp of that day as integer
//if date is invalid then returns 0 // $upper_or_lower = U or L
//if date is null thsi will return current timestamp
$timemsg="";
if(trim($Date)=="")
$timemsg=time();
else{
//spilit dates in parts
$DateParts = split( "[/-]" , $Date );

if( checkdate($DateParts[1],$DateParts[0],$DateParts[2]) ){
if( strtolower($upper_or_lower)=="u" )
$timemsg=mktime( 23,59,59,$DateParts[1],$DateParts[0], $DateParts[2] );
else
$timemsg=mktime( 0,0,0,$DateParts[1],$DateParts[0], $DateParts[2] );
}else
$timemsg=0;
}
return $timemsg;
}





How to call this function?



$lowerTimeStamp= getTimeStamp("22/10/2010","l");
$upperTimeStamp= getTimeStamp("22/10/2010","u");
$currentTimeStamp= getTimeStamp();







How to link to this page?
If you wish to link to this page from your website, simply Copy and paste the above HTML code to your web page. It will appear on your page as:
PHP Function to return upper and lower time stamp of a given date.




Share this!




comments powered by Disqus

This Weeks 7 Popular Posts


Subscribe to Recent Posts by Email
Stay connected to CROZOOM with regular Email notices of new Techie articles and IT Jobs. Updates will be delivered to your Inbox as soon as they are posted online.

Enter Your Email Address:  

Delivered by FeedBurner   RSS Feed

Search this Blog   



Urgent Openings for PHP trainees, Andriod / IOS developers and PHP developers in Kochi Trivandrum Calicut and Bangalore. Please Send Your updated resumes to recruit.vo@gmail.com   Read more »