week-number.net
Programming Languages
- Java
- PHP
- Python
- Shell Script
- Perl
- MySQL
Week number in PHP
Getting the week number for a date in PHP is simple. Just use the powerful date()
function that takes
a format string and an optional unix timestamp as arguments. If you omit the second argument, it returns
the current date/time in the given format.
Example
Get the current week number and print it.
$currentWeekNumber = date('W');
echo 'Week number:' . $currentWeekNumber;
Output:
Week number:8
comments powered by Disqus