Convert Date Format

Convert  Date Format

Subtract hours from currenttime:

$date = date("Y-m-d H:i:s"); // Current date and time

$currentDate = strtotime($date); // Convert into Unix timestamp

$time = $currentDate - (2 * 60 * 60); // Subtract hours from currentdate

$datetime = date("Y-m-d H:i:s", $time); // Date and time after subtraction

Subtract Minutes from currenttime:

$date = date("Y-m-d H:i:s"); // Current date and time

$currentDate = strtotime($date); // Convert into Unix timestamp

$time = $currentDate - (5 * 60); // Subtract Minutes from currentdate

$datetime = date("Y-m-d H:i:s", $time); // Date and time after subtraction

Subtract Seconds from Datetime

$date = date("Y-m-d H:i:s"); // Current date and time

$currentDate = strtotime($date); // Convert into Unix timestamp

$time = $currentDate - 50; // Subtract Seconds from currentdate

$datetime = date("Y-m-d H:i:s", $time); // Date and time after subtraction



Copyright © 2024 Tridhya Tech Limited, Inc. All rights reserved.