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
Related
For some reason, strtotime is not working correctly.
date('m', strtotime('Nov'));
is yielding 12.
What am I doing wrong?
If you don't provide a day, PHP will assume today which is the 31st. There is no 31st of November so PHP uses what would be the equivalent of the next day after the 30th which is the 1st of December. So you get 12 for December.
If you want an accurate date, be more specific. In this case, use the first day of the month.
date('m', strtotime('first day of Nov'));
Demo
It is giving correct date but not the correct day value.Why..?
What I want day is the date for monday for the current week which can be generated on any day of the week. so what I did was, I'm taking the today's day and comparing with (Mon,Tue.... Sun) and respectively creating a timestamp using
You can use date("Y-m-d",strtotime("monday")); to find out next Monday.
To find Monday from any day of the week you can try this-
$date="2018-08-01"; //any day of the week
$day=date("N",strtotime($date));
if($day>1){
$date=date("Y-m-d",strtotime("$date -1 week"));
}
echo date("Y-m-d",strtotime("$date monday"));
Didn't sure what you really want but if you want current day date simply use getdate() function
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()
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'));
I need to generate a timestamp for an exact date in the next month.
I want to generate the timestamp for the 10th of the next month automatically.
I tried playing around with strtotime but couldn't work it out.
Thanks,
Try this:
echo date('Y-m-d', strtotime(date('Y-m-10'). '+1 month'));