strtotime

How to specify saturday as a week day for strtotime

故事扮演 提交于 2021-02-10 08:32:56
问题 I need to add 2 business days to the current date. I was going to use strtotime for it, but strtotime's weekdays don't include saturday. $now = date("Y-m-d H:i:s"); $add = 2; $format = "d.m.Y"; if(date('H') < 12) { $add = 1; } $date = strtotime($now . ' +'.$add.' weekdays'); echo date($format, $date); This would output Tuesday if you run it on Friday. But it actually should return Monday. How can i add Saturday as a weekday? 回答1: Get next business day from specific date + number of day offset

Save custom delivery date from product attribute on WooCommerce order

半世苍凉 提交于 2020-07-16 05:46:08
问题 i have a custom attribute where products have different pickup times. i want to add this dates as a custom field to my wc orders, to notify my customers via cronjob that the order is ready to pickup. with the code below i get the wrong date, can anyone tell me what is wrong here? foreach ( $order->get_items() as $item_id => $item ) { $product_id = $item->get_product_id(); $order_id = $order->get_id(); $new_product = new WC_Product( $product_id ); // create an object of WC_Product class //

strtotime not inserting into database

[亡魂溺海] 提交于 2020-05-09 07:46:05
问题 So Im scraping a website for data, and one piece of data that im scraping is the date of certain items. The date of the items comes in the format "Wed 11th March, 2015". I have been trying to then insert this into my mysql database. The structure of the database contains a column with "datapublished" as a Timestamp, `feeddatapublished` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP) When updating the rest of the columns with the data it updates fine with the

Given a Unix timestamp, how to get beginning and end of that day?

China☆狼群 提交于 2020-04-05 07:12:08
问题 I have a Unix timestamp like this: $timestamp=1330581600 How do I get the beginning of the day and the end of the day for that timestamp? e.g. $beginOfDay = Start of Timestamp's Day $endOfDay = End of Timestamp's Day I tried this: $endOfDay = $timestamp + (60 * 60 * 23); But I don't think it'll work because the timestamp itself isn't the exact beginning of the day. 回答1: strtotime can be used to to quickly chop off the hour/minutes/seconds $beginOfDay = strtotime("today", $timestamp);

Given a Unix timestamp, how to get beginning and end of that day?

萝らか妹 提交于 2020-04-05 07:11:50
问题 I have a Unix timestamp like this: $timestamp=1330581600 How do I get the beginning of the day and the end of the day for that timestamp? e.g. $beginOfDay = Start of Timestamp's Day $endOfDay = End of Timestamp's Day I tried this: $endOfDay = $timestamp + (60 * 60 * 23); But I don't think it'll work because the timestamp itself isn't the exact beginning of the day. 回答1: strtotime can be used to to quickly chop off the hour/minutes/seconds $beginOfDay = strtotime("today", $timestamp);