Issue
I need to display Future Date in a webpage. like 24 days after today only month and day. can anyone please help me. Like
This item will deliver in :(+24 days). e.g. This item will deliver in: Dec 6
I like to Display Month and Day only, is it possible. Thank you. PS. I am using WordPress and WPBakery Page Builder
Solution
Add this into your functions.php and output with shortocde
[delivery_date]
function delivery_date_shortcode() {
// Get today date
$today = new DateTime();
// Add 24 days to today date
$delivery_date = $today->modify('+24 days');
$formatted_date = $delivery_date->format('M j');
// Return the formatted date
return "This item will deliver in: {$formatted_date}";
}
// Register the shortcode
add_shortcode('delivery_date', 'delivery_date_shortcode');
Answered By - Aquaxetinez
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.