I need to get the current time, in Hour:Min format can any one help me in this.
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
You have to set the correct timezone in
php.ini
.Look for these lines:
It will be something like :
Don't forget to restart your webserver.
You can use the following solution to solve your problem:
Try this:
This will be 24-hour time with an hour that is always two digits. For all options, see the PHP docs for date().
Should do it, for the current time. Use a lower case h for 12 hour clock instead of 24 hour.
In addressing your comment that you need your current time, and not the system time, you will have to make an adjustment yourself, there are 3600 seconds in an hour (the unit timestamps use), so use that. for example, if your system time was one hour behind:
$time = date('H:i',time() + 3600);