Jump to content

php date help


phporcaffeine

Recommended Posts

I need to be able to tell the next day, no matter what the current day is.  I am having trouble when it comes to the ends of the month.

<?php

$day = date("j") + 86400;

echo "Tomorrow is: " . date("m/") . $day . "/" . date("Y");

// this works fine until you encounter the 30th or 31st of a month, how do I account for that?

?>

-TIA
Link to comment
https://forums.phpfreaks.com/topic/22973-php-date-help/
Share on other sites

[quote author=pedrobcabral link=topic=110474.msg446631#msg446631 date=1159967276]
My ignorance made me do a code like to cal_days_in_month.. see if it was december blablabla, just to achieve a thing as simple as that!
[/quote]

hehe... we've all been there, [b]believe[/b] me... that's why this board is here: to help learn new techniques ;)
Link to comment
https://forums.phpfreaks.com/topic/22973-php-date-help/#findComment-103695
Share on other sites

If you want to go one day more for the present then you ho that way.
Imagine now you want to go one day more, but not from the present day.

I'm trying somethings but I'm not suceding.. i've this one now: date('20-01-1986',strtotime("tomorrow"));
Do you know what's the problem here to have in the output: 21-01-1982?
Link to comment
https://forums.phpfreaks.com/topic/22973-php-date-help/#findComment-103715
Share on other sites

keep in mind the arguments that date requires. the first argument is your [b]format[/b] and the second is a [b]UNIX timestamp[/b]. so, strtotime gets that timestamp for you:
[code]
<?php
$date = "1986-01-20";
echo date('m/j/Y', strtotime("$date +1 day"));
?>
[/code]

read up on the [url=http://www.php.net/strtotime]strtotime()[/url] and [url=http://www.php.net/date]date()[/url] pages in the manual to get a better feel for what is and is not readable to them.
Link to comment
https://forums.phpfreaks.com/topic/22973-php-date-help/#findComment-103728
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.