I need to know the date of next Friday. Known only today's date.
PHP / Framework Laravel 5.1
How do I know the date of the next Friday?
Thank you!
This is nice and easy using strtotime
strtotime('next friday');
See strtotime()
Related
I need to find the date number for the first day of the current week. For example if the date is 05/06.2015 I want to get as a result 29/05/2015 where Monday is the firs day of the week. I'm not very familiar with PHP date functions because I'm new at it. Can someone show me how to find it? Thanks!
strtotime is a powerful function.
echo date("j/n/Y", strtotime('monday this week'));
So I am having a little trouble getting today's midnight date using the midnight time using the time() function.
It is a little confusing for me when I explain to my peers on the timestamp I want. What I need is, if today is wed-06-Aug-2014 at 9:00pm , then I want the time at wed-06-Aug-2014 00:00.
Any help?
Just use relative date and time formats:
echo date('D-d-M-Y H:i', strtotime('midnight'));
Demo
I'm trying to get the starting monday date of the actual week we are in. Like we are July 15th and would like to have the result with strtotime to return July 11th...
I've tried
strtotime("-1 weekdays");
Without luck... What could be the function for the actual week please.
Thanks
$timestamp = strotime('monday this week');
Will give you Monday! ;)
Did none of these help you to find your answer?
Get first day of week in PHP?
Finding First day of week via php
First date of a week
How would I go about getting the date of say the 32 Wed of a given year. Is there an easy way to do this that I am missing?
It is worth noting, that strtotime() accepts ISO week date format (for example "2008-W27-2" is Tuesday of week 27 in 2008), so it can be easily used to get the date of a given week number.
Source
echo date("d m Y", strtotime("2010-W32-3"));
i think... :p
Edit: W32 is the week number and 3 is the day of the week (1-7)
Or maybe something more complicated like this - its a bit pointless if the above works - but was just thinking of alternatives... I don't know if it would work. :p Just for fun.
echo date("d m Y", strtotime("1-1-2010 + 32 Weeks ".date("N", "Wednesday")." Days"));
maybe, but now I'm clutching at straws ha. :)
Does anyone know of a php class or library that helps deal with dates (meaning weekdays)? For example, I could use it to say "give me the timestamp for next Tuesday at 9:00" or "is this timestamp between next Tuesday and next Thursday".
I just have a part of my application that I need to make sure I'm not scheduling things at certain times.
There is the built-in DateTime class, but you don't even need it for this:
//this gives results in the default timezone
//timestamp for next Tuesday at 9:00
strtotime("next tuesday 09:00");
//is this timestamp between next Tuesday and next Thursday
$ts >= strtotime("next tuesday") && $ts < strtotime("next friday")
Can you use strtotime()?
http://php.net/strtotime
If you must use a class Zend_Date is quite powerful. It comes with the Zend framework but is pretty standalone as far as I know. No obligation to implement MVC and all the other Zend stuff.
Some of the comments in the PHP manual explain how to do this with date.