date()
FunctionYou can simply use the PHP date()
function to get the current data and time in various format, for example, date('d-m-y h:i:s')
, date('d/m/y H:i:s')
, and so on.
Try out the following example to see how it basically works:
<?php
// Return current date from the remote server
$date = date('d-m-y h:i:s');
echo $date;
?>
The date and time returned by the above example is based on the server's default timezone setting. If you want to show date and time as per user's timezone, you can set the timezone manually using the date_default_timezone_set()
function before the date()
function call.
The following example shows the date and time in India timezone which is Asia/Kolkata
.
<?php
// Set the new timezone
date_default_timezone_set('Asia/Kolkata');
$date = date('d-m-y h:i:s');
echo $date;
?>
Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]
How to Check If the Mouse is Over an Element in jQuery
Use the CSS :hover Pseudo-class You c...How to Create REST API in Laravel7 using JWT
Hello Artisan In this tutorial...How to Upload Image in Laravel 8 using Summernote Editor
Summernote editor is a simple Javascript...How to find string length in PHP
Use the PHP strlen() function...Get and Set attribute value using jQuery attr method
jQuery attr() method is used to get firs...