Asked  7 Months ago    Answers:  5   Viewed   26 times

first let me show you my code:

$lastWeek = date('m-d-Y', strtotime('-1 week'));

That's how to get the timestamp from last week. Is there a chance I gan get the timestamp from last saturday?

I hope you know what I mean.

Thanks a lot.



What's wrong with

$last_sat = strtotime("last Saturday"); 


The time should be set to '00:00:00';

echo date('d-M-Y H:i:s',$last_sat);


29-Jan-2011 00:00:00
Wednesday, March 31, 2021
answered 7 Months ago

You could also take a look at the DatePeriod class:

$period = new DatePeriod(
     new DateTime('2010-10-01'),
     new DateInterval('P1D'),
     new DateTime('2010-10-05')

Which should get you an array with DateTime objects.

To iterate

foreach ($period as $key => $value) {
Wednesday, March 31, 2021
answered 7 Months ago

You need to call DateInterval::format() to display that difference as a string.

echo $diff->format('%d days');

See the manual for all of the available formatting options.

Wednesday, July 7, 2021
answered 4 Months ago

use SimpleDateFormat, see tutorial here. But it's not recommended this approach, if you save it as a long, you can compare it, order, etc...

Saturday, August 21, 2021
Aniket Thakur
answered 2 Months ago

That's currently not possible with the Telegram Bot API.

Thursday, October 14, 2021
answered 1 Week ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :