In my first post I want to present you all a simple PHP time age function. This function can calculate Linux timestamps and returns how much time ago it occurred. As we saw other social networking sites (like Facebook, Twitter, YouTube). If we post something on these sites we can see how much time ago it was posted.
Like one minute ago, 2 hour ago, 3month ago or even some years ago. I have implement a simple function that can do exactly like this job. The input form of this function is integer as timestamps( time() ) and it will return string.
The time ago Function:
Usages:
Output:
Like one minute ago, 2 hour ago, 3month ago or even some years ago. I have implement a simple function that can do exactly like this job. The input form of this function is integer as timestamps( time() ) and it will return string.
The time ago Function:
/** * Time Ago Using PHP * @param int $timestamp * @return string */ function timeAgo($timestamp){ $time = time() - $timestamp; if ($time < 60) return ( $time > 1 ) ? $time . ' seconds' : 'a second'; elseif ($time < 3600) { $tmp = floor($time / 60); return ($tmp > 1) ? $tmp . ' minutes' : ' a minute'; } elseif ($time < 86400) { $tmp = floor($time / 3600); return ($tmp > 1) ? $tmp . ' hours' : ' a hour'; } elseif ($time < 2592000) { $tmp = floor($time / 86400); return ($tmp > 1) ? $tmp . ' days' : ' a day'; } elseif ($time < 946080000) { $tmp = floor($time / 2592000); return ($tmp > 1) ? $tmp . ' months' : ' a month'; } else { $tmp = floor($time / 946080000); return ($tmp > 1) ? $tmp . ' years' : ' a year'; } }
Usages:
echo 'About '. timeAgo(time()-60*2) .' ago';
Output:
About 2 minute ago
GOOOOOOOOOD LOVE THIS TUTORIAL IS EASY
ReplyDeleteThanks. That's really helpful.
ReplyDeleteThis is really helpful tutorial, thanks to share with us :) I also recently wrote another PHP time ago function, hope this also help.
ReplyDeletehttps://htmlcssphptutorial.wordpress.com/2015/08/21/time-ago-php-function/
Thanks for some other excellent post. I enjoyed your post. If any one want to get more about Memphis local SEO service you may visit Memphis SEO .
ReplyDeletekhoanh chân ngồi ở bên trong lò, gương mặt không còn chút máu, tính mạng
đang dần mất đi.
Ánh mắt Vương Lâm không chút dao động, hắn huy động cánh tay, Dẫn Lực
thuật theo đó tùy ý động, hướng về phía lò luyện đan chộp đến. Từng đạo
học kế toán thực hành
forum rao vặt cattleya
học kế toán tổng hợp
eco-green-city
học kế toán tại bắc ninh
dịch vụ kế toán trọn gói
chung cư hà nội
dịch vụ làm báo cáo tài chính cuối năm
manor central park
dịch vụ làm báo cáo tài chính
kế toán cho quản lý
khoá học kế toán thuế
keny idol
trung tâm kế toán tại long biên
trung tâm kế toán tại hải phòng
ngũ thải quang mang từ trong lò luyện đan xuất hiện, tạo thành một chiếc
màn che va chạm với bàn tay vô hình do Dẫn Lực thuật tạo ra.
Vương Lâm hừ lạnh một tiếng, linh lực trong cơ thể được vận chuyển nhất
thời uy lực của Dẫn Lực Thuật tăng lên so với trước rất nhiều lần, nó
lập tức nghiền nát tấm màn che do ngũ thải quang mang tạo thành. Vương
Lâm lao vào ôm lấy Vương Hạo, đưa hắn ra khỏi lò luyện đan đặt lên trên
mặt đất.
máy chạy bộ điện bàn bóng bàn giàn tập tạ
ReplyDeleteشراء اثاث مستعمل بالرياض
ReplyDeleteشراء الاثاث المستعمل بالرياض
شركة شراء اثاث مستعمل بالرياض
شركة شراء الاثاث المستعمل بالرياض
تركيب مكيفات
ReplyDeleteفني مكيفات
مشروع صيانة مكيفات
شركة صيانة مكيفات
صيانة مكيفات اسبليت
صيانة مكيفات بالرياض
تصليح مكيفات
شركة تصليح مكيفات اسبليت
صيانة التكييف المنزلي
فني تركيب مكيفات
صيانة مكيفات اسبليت
I have read your blog its very attractive and impressive. I like it your blog.
ReplyDeletePHP Training in chennai | PHP Training Course
PHP Training in chennai | Online PHP Course
I have read your blog its very attractive and impressive. I like it your blog.
ReplyDeletePHP Training in chennai | PHP Training Course
PHP Training in chennai | Online PHP Course
yoga hà nội
ReplyDeleteyoga thanh lọc cơ thể
ReplyDelete
ReplyDeletedownload asphalt nitro mod apk ddownload dead trigger 2 mod apk