WP - Date Function
WP - Date Function
php
Date_default_timezone_set(‘Asia/Kolkata’);
$date = date_create(‘2024-11-12’);
$date1 = date_create(‘2024-11-12’);
$date2 = date_create(‘2024-12-25’);
$timestamp = 1731403200;
?>
Explanation
Let’s go through each function and its parameters used in the PHP program:
Date_default_timezone_set
Purpose: Sets the default timezone used by all date/time functions in a script.
Parameters:
Date
Parameters:
Format: A string specifying the format of the outputted date string (e.g., ‘Y-m-d H:i:s’).
Timestamp (optional): An integer Unix timestamp. If omitted, the current time is used.
Date_create
Parameters:
Time (optional): A string representing a date/time (e.g., ‘2024-11-12’). If omitted, the current date and
time are used.
Date_format
Parameters:
Format: A string specifying the format of the outputted date string (e.g., ‘l, F jS, Y’).
Date_add
Parameters:
Date_interval_create_from_date_string
Parameters:
Date_sub
Parameters:
Date_diff
Parameters:
Absolute (optional): A boolean indicating whether to return an absolute difference. Default is FALSE.
Date_sun_info
Purpose: Returns an array with information about sunset/sunrise and twilight begin/end.
Parameters:
Time
Parameters: None.
Parameters:
Format: A string specifying the format of the outputted date string (e.g., ‘Y-m-d H:i:s’).