Retrieving system date in PHP
How do I get the system date and time i开发者_如何转开发n this format:
$systime="12/january/2010 10.30 AM "
To get exactly what you've asked for, you'll need to use strtolower()
and date
:
$systime = strtolower(date("d/F/Y G.i")) . " " . date("A") . " ";
You need strtolower
because there's no built-in way to get lowercase month values, so you need to get that part as January
and then transform it to lowercase. You can't lowercase the whole thing because you seem to want AM
or PM
rather than am
or pm
.
Using date and strftime() we can get the system date.
Example:
echo date("d/F/Y g:i A");//It prints 05/March/2010 12:18 PM
echo strftime("%d/%B/%Y %I:%M %p"); //It prints 05/March/2010 12:20 PM
Try:
$systime = date('d/F/o g i A');
Sample output:
05/March/2010 7 27 AM
date() and time()
精彩评论