Learn how to obtain a date in the format '2023-06-13T00:55:44+05:30' using PHP. Step-by-step guide for date manipulation in PHP.
To get the current date in the format '2023-06-13T00:55:44+05:30' in PHP, you can use the following code:
<?php date_default_timezone_set('Asia/Kolkata'); // Set the desired timezone $currentDate = date('Y-m-d\TH:i:sP'); // Format the date echo $currentDate; // Output: 2023-06-13T00:55:44+05:30 ?>
In this code, date_default_timezone_set is used to set the desired timezone. If needed, you can replace 'Asia/Kolkata' with your specific timezone.
Then, the date is used to format the date according to the specified format. In this case, 'Y-m-d\TH:i:sP' is used, where:
Finally, echo is used to output the formatted date.
I hope you found the above information helpful. Please let me know in the comment box if you have an alternate answer π₯ and you can support me by buying me a coffee.
And donβt forget to sign up to our email newsletter so you can get useful content like this sent right to your inbox!
Thanks!
Faraz π