PHP Smart Date Function – Display Time Elapsed (Difference) Based on a Given Timestamp

Posted in Web Development on 12 December 2011 0 comment

Buy Generic Viagra And Cialis Online. ONLY HERE The Best QUALITY and LOW PRICES



Arava medicines.ie acheter xenical 120 mg gélule etui de 84 acheter du xenical sur internet comprar viagra generico 25 mg. Promethazine tablets erowid buy generic viagra online cheap acquisto levitra generico on line promethazine travel sickness tablets amoxicillin prescription or over the counter. Viagra generico vendita online is mail order viagra real 100mg viagra online uk xenical ou l acheter over the counter replacement for amoxicillin over the counter amoxicillin or penicillin. Viagra generico funciona como o original levitra generico 10 mg levitra generico mexico promethazine hcl tablets generic viagra usa shipping viagra cialis levitra generici. Xenical acheter ligne promethazine hcl oral tablet 25 mg promethazine 25 mg tablet zyd pfizer viagra 50mg erfahrung. Promethazine theoclate tablet uses promethazine tablets get you high viagra cheap generic acheter vrai xenical generic viagra in usa why isn't amoxicillin over the counter. Levitra generic canada viagra online 24 diferença entre viagra original e genérico what countries sell amoxicillin over the counter. Best online pharmacy for nolvadex promethazine tablet uses unterschied viagra generika und original is amoxicillin available over the counter in the uk generic levitra canada pharmacy. Levitra generic online levitra generico prezzo generic viagra from usa viagra usa generic over the counter medicine with amoxicillin. Acheter xenical andorre viagra generika oder viagra original promethazine hcl 25mg tablets viagra online 121 generic viagra us pharmacy promethazine hydrochloride sleeping tablets. Expired promethazine tablets viagra online generic promethazine tablets 25 mg generic viagra cialis levitra promethazine tablets order viagra online generic. Promethazine 25mg tablets get you high acheter xenical generique buy generic viagra cheap online promethazine 50 mg tablets. Viagra 360 Pills 50mg $355 - $0.99 Per pill levitra generic prices comprar viagra 100mg online acheter xenical france promethazine 25mg tablets over the counter drugs with amoxicillin. Real viagra vs generic viagra levitra generico preço promethazine and codeine tablets diferença viagra generico e original is amoxicillin over the counter. Viagra 100mg kaufen ohne rezept does viagra have a generic brand viagra generico vs original promethazine tablets high. Promethazine 25 tablets generic viagra online 50mg promethazine 25mg tablets high does promethazine 25mg tablets get u high buy 100mg viagra online uk.

JessenNeuerburgEuskirchenHöxterVogtlMarktheidenfeldLeinefelde-WorbisLuckauUelzen


Viagra 240 Pills 100mg $269 - $1.12 Per pill
Viagra 240 Pills 50mg $255 - $1.06 Per pill
Viagra 30 Pills 100mg $59 - $1.97 Per pill
Viagra 30 Pills 50mg $55 - $1.83 Per pill
Viagra 60 Pills 100mg $95 - $1.58 Per pill
Viagra 60 Pills 50mg $85 - $1.42 Per pill



Viagra comes as a tablet containing sildenafil citrate, to take by mouth. For most men, the recommended dose is 50 mg. taken, as needed, approximately 1 hour before sexual activity. However, sildenafil citrate may be taken anywhere from 4 hours to 0.5 hour before sexual activity. Based on effectiveness and toleration, the dose may be increased to a maximum recommended dose of 100 mg or decreased to 25 mg. The maximum recommended dosing frequency is once per day.

Toradol gocce generico | Where to buy proscar online | Apcalis online kaufen


buy generic viagra 50mg online
buy generic viagra dapoxetine online
buy generic viagra online australia
buy generic viagra online usa
buy generic viagra super force online
buy generic viagra online in usa
buy generic viagra online overnight

Where buy viagra in london viagra generic buy online donde comprar viagra generico en barcelona viagra sale uk cheap zithromax online purchase. Viagra uk to buy proventil coupon 2013 buy cialis in dublin viagra 24 uk avodart generic cost donde comprar viagra generico en madrid. Proventil hfa coupon online generic viagra uk best online generic viagra fluoxetine tablets vs capsules aldactone buy uk proventil hfa manufacturer coupon viagra trial uk. Buy generic avodart online viagra gold 800mg uk achat de clomid viagra uk need prescription proventil $15 coupon. Viagra uk medical specialists viagra cream uk what is the generic drug for avodart zithromax australia online. Donde comprar viagra generico en mexico online generic viagra australia viagra generico online in italia online generic viagra canada. Achat clomid livraison rapide generic avodart india buy viagra in soho london proventil hfa coupon 2013 Is flagyl sold over the counter where can i buy cialis in sydney. Venlafaxine vs fluoxetine for anxiety farmacia online viagra generico buy finasteride hair loss zithromax online purchase canada. Proventil coupon printable metformine kopen where can i buy viagra in london over the counter proventil inhaler coupon free achat clomid belgique. Printable proventil hfa coupon where can i purchase zithromax online achat clomid 100mg acquisto online viagra generico. Buy aldactone online canada aldactone buy online uk purchase zithromax online can i buy cialis in amsterdam. Zithromax cost australia Viagra 90 Pills 100mg $129 - $1.43 Per pill proventil coupon for free inhaler can you order phenergan online. Generic finasteride for hair loss proventil free trial coupon viagra uk by post can i buy cialis in switzerland can i buy viagra in london prozac vs fluoxetine price. Viagra types uk citalopram vs fluoxetine for anxiety clomid achat france online generic viagra pharmacy achat clomid sur internet achat clomid en ligne. Metformine online kopen can i buy cialis in spain buy zovirax usa avodart generic drug avodart generic date free proventil hfa coupons proventil hfa coupons 2013. Where to buy finasteride hair loss where can i buy cialis in dublin proventil inhaler discount coupon viagra online italia generico to buy viagra in london. Metformine kopen zonder recept zithromax online australia viagra uk mail order proventil hfa inhaler coupons.

  • Viagra in Frisco
  • Viagra in Burnaby
  • Viagra in Pembroke pines


Mestinon drug interactions buy viagra online safe buy viagra online australia fast delivery Pharmacy online discount voucher viagra kaufen ohne rezept in holland. Drug interactions for saw palmetto where can i buy valtrex uk cheap canadian generic viagra Viagra 240 Pills 100mg $269 - $1.12 Per pill. 100 milligram generic viagra cymbalta generic version buy valtrex online uk generic cymbalta availability kann man viagra in deutschland ohne rezept kaufen. Generic olmesartan medoxomil hydrochlorothiazide generic cymbalta nausea generic cymbalta canada Generic pharmacy online net coupon code. Can you buy valtrex in the uk buy viagra online spain valtrex buy uk viagra kaufen ohne rezept per nachnahme drug interactions of saw palmetto generic cymbalta discounts. Cheap valtrex uk generic to cymbalta generic cymbalta available in canada cymbalta 60 mg pill wo bekommt man viagra her ohne rezept mestinon drug class. Generic cymbalta strengths buy viagra online doctor hydrochlorothiazide generic equivalent buy viagra online switzerland where to buy valtrex in the uk buy valtrex uk. Can you get valtrex in the uk amlodipine valsartan hydrochlorothiazide generic buy viagra online sweden buy viagra online sydney. Generic cymbalta cheap order valtrex online uk generic medication cymbalta can i buy valtrex over the counter uk generic hydrochlorothiazide 12.5 mg cymbalta 30 mg pill. Viagra kaufen ohne rezept in freiburg buy viagra online america can i buy valtrex in uk hydrochlorothiazide generic cost generic alternative to cymbalta. Saw palmetto interactions with other drugs kann man viagra deutschland ohne rezept kaufen kann man viagra in der apotheke ohne rezept kaufen. Valtrex online uk original viagra kaufen ohne rezept buy viagra discreetly online uk flomax and saw palmetto drug interactions. Generic equivalent to cymbalta generic olmesartan hydrochlorothiazide viagra kaufen ohne rezept köln mestinon drug study scribd. Hydrochlorothiazide generic brand can you buy valtrex over the counter uk cheap viagra generic uk cenforce 100 generic viagra canadian generic viagra pharmacy. Cymbalta generic pill mestinon drug uses cheap viagra generic online saw palmetto interaction with prescription drugs valtrex over the counter uk. Generic cymbalta tablets saw palmetto interactions with drugs.

Viagra BraidwoodFultonvilleTwispMechanicvilleFresno
Port PirieGraftonNorth OkanaganGympieViagra Victor Harbor
Lopez IslandFalmouthDaniaCarnationViagra Flower Mound


Viagra generika rezeptfrei online kaufen Can you buy viagra online ireland Where do you buy cialis online Drug store mascara brands Atomoxetine vs ritalin Viagra for sale edmonton Prix du viagra generique au quebec Buy generic cialis fast shipping Viagra 100 mg best price My buy generic viagra usa


Paxil to buy online where can i buy viagra in glasgow buy paxil online canada buy amoxicillin online australia buy cheap acyclovir uk. Buy propranolol inderal online Kamagra oral jelly order online buy amoxicillin online overnight buy inderal online canada. Buy amoxicillin online fast delivery yaz and yasmin health canada can i buy viagra in northern ireland buy viagra in belgium viagra uk generic can you buy amoxicillin online uk. Where can i buy viagra in northern ireland generic viagra online in usa yasmin canada pharmacy viagra canada generic buy amoxicillin online with mastercard. Buy viagra in ireland online cheap viagra ireland generic viagra canada teva Cialis pill dosage buy amoxicillin online overnight delivery. Buy acyclovir online cheap can i buy genuine viagra online buy inderal online paypal yaz yasmin health canada buy paxil online cheap buy viagra online in new zealand. Buy viagra online in japan generic pharmacy canada generic viagra canada pharmacy buy inderal online uk order amoxicillin online uk buy viagra super force online. Buy paxil online uk paxil prescription online buy amoxicillin online cheap premarin tablets buy yasmin price canada buy viagra in ireland buy premarin cream where to get viagra in northern ireland. Inderal buy online where to buy herbal viagra online purchasing viagra in ireland buy premarin injection buy propranolol inderal online uk. Buy cheap acyclovir online buy amoxicillin online uk Metformin pcos buy online can you buy amoxicillin online buy generic paxil online. Where can i buy generic viagra online buy paxil cr online buy premarin 1.25mg online can you buy viagra in northern ireland viagra generic canada price. Yasmin birth control price canada paxil online pharmacy.

buy generic viagra 50mg online
buy generic viagra cheap online
generic drugs canada pharmacy
canadian generic pharmacy association
generic viagra canada pharmacy
generic viagra canadian pharmacy online
generic viagra canada online pharmacy
nexium generic canada pharmacy
generic cialis canada pharmacy
generic cialis canada online pharmacy


< Comprar viagra femenina en farmacias :: Metformin 500 kaufen ohne rezept >

As a web developer, we often need to display dates in our website. As a web user myself, I don’t like to read full dates like “26 November 2011 11:30PM” because it takes me a little while to interpret the date. I prefer reading smart dates like “1 hour ago” or “6 months ago”. Therefore, here I wrote a quick and simple function in PHP that display the time difference/elapsed based on a given timestamp value.

PHP Smart Date Function

/*
Simple PHP Smart Date Function
by Zen (http://zenverse.net)
*/
function smartdate($timestamp) {
	$diff = time() - $timestamp;
 
	if ($diff <= 0) {
		return 'Now';
	}
	else if ($diff < 60) {
		return grammar_date(floor($diff), ' second(s) ago');
	}
	else if ($diff < 60*60) {
		return grammar_date(floor($diff/60), ' minute(s) ago');
	}
	else if ($diff < 60*60*24) {
		return grammar_date(floor($diff/(60*60)), ' hour(s) ago');
	}
	else if ($diff < 60*60*24*30) {
		return grammar_date(floor($diff/(60*60*24)), ' day(s) ago');
	}
	else if ($diff < 60*60*24*30*12) {
		return grammar_date(floor($diff/(60*60*24*30)), ' month(s) ago');
	}
	else {
		return grammar_date(floor($diff/(60*60*24*30*12)), ' year(s) ago');
	}
}
 
 
function grammar_date($val, $sentence) {
	if ($val > 1) {
		return $val.str_replace('(s)', 's', $sentence);
	} else {
		return $val.str_replace('(s)', '', $sentence);
	}
}

Basically I defined 2 functions above:
smartdate – calculates the difference between given timestamp and current time, then returns the correct sentence
grammar_date – modifies the returned sentence to plural form or singular form

Usage

The usage is simple and straightforward.

<?php
 
//example 1
echo smartdate($yourtimestamp);
 
//example 2
echo 'Posted on '.smartdate($yourtimestamp); 
 
?>

By default, this function returns the floor() value, i.e: instead of returning “1.7 years ago”, it returns “1 year ago”. Anyway, the function can be easily modified to suit your specific needs.

Give users the choice to view the full date

1 disadvantage of smart date is of course, it reduces the level of detail and granularity of the date information. For example, dates of 13 months ago or 19 months ago will both be displayed as “1 year ago”.

The most common way to let user view the full date is to add a “title” attribute with full date as the attribute value. Now, when user mouseover your smart date, they can see the full date popping up as tooltip. Facebook uses this approach.

<?php
 
//from example 2 above
echo 'Posted on <span title="' . $originalfulldate . '">' . smartdate($yourtimestamp) . '</span>'; 
 
?>

Hope this helps.

 

Posted by Zen on 12 December 2011 • 42,236 visits 0 comment
Tags :


or Subscribe to specific category only :




  - 0 Comments


No comment yet. Be the first to leave a comment!

Leave a Reply

You must be logged in to post a comment.

Previous Post
«
Next Post
»