phporcaffeine Posted October 4, 2006 Share Posted October 4, 2006 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 More sharing options...
Tandem Posted October 4, 2006 Share Posted October 4, 2006 http://us3.php.net/dateIf you look at example 3 it shows you how to do something similar using mktime and date together.Sorry i can't be of more help than that. Link to comment https://forums.phpfreaks.com/topic/22973-php-date-help/#findComment-103675 Share on other sites More sharing options...
printf Posted October 4, 2006 Share Posted October 4, 2006 It depends on your timezone, or use gm... to get the GMT![code]<?echo 'Tomorrow is: ' . date ( 'm/d/Y', mktime ( 0, 0, 0, date ( 'n' ), ( date ( 'j' ) + 1 ), date ( 'Y' ) ) );?>[/code]me! Link to comment https://forums.phpfreaks.com/topic/22973-php-date-help/#findComment-103676 Share on other sites More sharing options...
obsidian Posted October 4, 2006 Share Posted October 4, 2006 why not just do:[code]<?phpecho "Tomorrow is: " . date('m/j/Y', strtotime("tomorrow"));?>[/code] Link to comment https://forums.phpfreaks.com/topic/22973-php-date-help/#findComment-103681 Share on other sites More sharing options...
pedrobcabral Posted October 4, 2006 Share Posted October 4, 2006 Jesus! 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! :o Link to comment https://forums.phpfreaks.com/topic/22973-php-date-help/#findComment-103688 Share on other sites More sharing options...
obsidian Posted October 4, 2006 Share Posted October 4, 2006 [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 More sharing options...
pedrobcabral Posted October 4, 2006 Share Posted October 4, 2006 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 More sharing options...
obsidian Posted October 4, 2006 Share Posted October 4, 2006 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.