PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
JAB Creations
DevNet Resident
Posts: 2341 Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:
Post
by JAB Creations » Thu Jan 08, 2009 2:08 pm
Well here is the date/time, though what would be a good way of getting the time exactly five minutes ago?
Code: Select all
<?php
$date_current = date('o-m-d H:i:s');
echo $date_current;
echo '<div>-5 minutes</div>';
?>
Eran
DevNet Master
Posts: 3549 Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME
Post
by Eran » Thu Jan 08, 2009 2:24 pm
Code: Select all
$date_past = date('o-m-d H:i:s',time() - 5 * 60);
JAB Creations
DevNet Resident
Posts: 2341 Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:
Post
by JAB Creations » Thu Jan 08, 2009 2:26 pm
That is freaking awesome, thanks!
VladSun
DevNet Master
Posts: 4313 Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria
Post
by VladSun » Thu Jan 08, 2009 3:25 pm
Code: Select all
echo date('H:i:s', strtotime('5 minutes ago'));
There are 10 types of people in this world, those who understand binary and those who don't
JAB Creations
DevNet Resident
Posts: 2341 Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:
Post
by JAB Creations » Thu Jan 08, 2009 4:31 pm
VladSun, that's cool though I presume it takes additional resources to convert it to something along the lines of what pytrin posted?
VladSun
DevNet Master
Posts: 4313 Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria
Post
by VladSun » Thu Jan 08, 2009 4:38 pm
JAB Creations wrote: VladSun, that's cool though I presume it takes additional resources to convert it to something along the lines of what pytrin posted?
That's obvious
But ... next time you ask how to get e.g. "the second tuesday of a given month and year" I'll use strtotime again:
Code: Select all
date("Y-m-d", strtotime("second tuesday", mktime(0, 0, 0, $month, 0, $year)));
There are 10 types of people in this world, those who understand binary and those who don't