GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   quick php date help.. (https://gfy.com/showthread.php?t=961843)

xxweekxx 04-04-2010 10:20 AM

quick php date help..
 
<?php
echo date("m/d/y");
?>

that will echo current month/day/yr

how do i make it echo YESTERDAYs info

so instead of 04/06/10

it'l be 04/05/10

ottopottomouse 04-04-2010 10:25 AM

$yesterday=date("m/d/y", time()-86400);

carry on multiplying the seconds to get back more days

xxweekxx 04-04-2010 10:33 AM

so it'll be

<?php
$yesterday=date("m/d/y", time()-86400);
?>

natkejs 04-04-2010 02:39 PM

or

<?php
echo date("m/d/y",mktime(0,0,0,0,-1,0));
?>

that tells it to generate a date using todays date -1 day, so that would be yesterday.
change -1 to -7 and it will be one week ago and so on and so forth...

Brujah 04-04-2010 03:29 PM

Take a look at strtotime also, if you prefer. You can do a lot with it like; +1 day, -1 day, last monday, next tuesday, etc...
http://www.php.net/manual/en/function.strtotime.php

$yesterday = date('m/d/y', strtotime('-1 day'));

natkejs 04-05-2010 02:55 AM

Quote:

Originally Posted by Brujah (Post 17005752)
Take a look at strtotime also, if you prefer. You can do a lot with it like; +1 day, -1 day, last monday, next tuesday, etc...
http://www.php.net/manual/en/function.strtotime.php

$yesterday = date('m/d/y', strtotime('-1 day'));

very neat, never used it like that :)


All times are GMT -7. The time now is 03:00 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123