Hey ya guys, I was doing some searching around on the PHP manual and goggle and what not, and I couldn't find the answer.
What I'm trying to do is get the previous date. I saw a bunch of a things on getting the first and last day of the current month and what not, but nothing about previous day.
What I was thinking I could do is take the current day, -1 to it and that would give me the right number and if it =0 then do an if() and -1 to month then get last day of the previous month.
Thoughts?
Get last day?
Moderator: General Moderators
- angelicodin
- Forum Commoner
- Posts: 81
- Joined: Fri Nov 13, 2009 3:17 am
- Location: Oregon, USA
Re: Get last day?
Code: Select all
strtotime("yesterday")- angelicodin
- Forum Commoner
- Posts: 81
- Joined: Fri Nov 13, 2009 3:17 am
- Location: Oregon, USA
Re: Get last day?
you sir are a godsend ;p
Re: Get last day?
I will use something like this (adjust to your needs):
Code: Select all
<?php
$Today = time();
$Tomorrow = $Today + 86400;
$Yesterday = $Today - 86400;
echo 'Today = ' . date('Y-m-d',$Today) . ' Tomorrow = '. date('Y-m-d',$Tomorrow) . ' Yesterday = '. date('Y-m-d',$Yesterday) . "<br /";
$nextWeek = $Today + (7 * 24 * 60 * 60); // 7 days; 24 hours; 60 mins; 60secs ... or 7 * 86400
echo 'Next Week: '. date('Y-m-d', $nextWeek) ."<br />";
// or using strtotime():
echo 'Next Week: '. date('Y-m-d', strtotime('+1 week')) ."<br />";
?>Re: Get last day?
Except twice a year it won't behave correctly.mikosiko wrote:I will use something like this (adjust to your needs):
Re: Get last day?
You are right tasairis.... I was trying to transmit him the concept of how to work with unix-like timestamps ... Y let the DST out of the picture
- angelicodin
- Forum Commoner
- Posts: 81
- Joined: Fri Nov 13, 2009 3:17 am
- Location: Oregon, USA
Re: Get last day?
Thank you all of you, seems I have more to learn time formatting and manipulation. Brilliant.