How to get current year in PHP: simple ways and examples
Hello everyone! I'm just starting to learn PHP and I've encountered what seems like a simple task: I need to display the current year (e.g., 2025) on the page in the site footer for copyright. I know PHP has the date() function, but I can't figure out how to use it correctly.
I tried this code:
```php
echo date("Y");
```
But it outputs something strange — "2025" with some extra characters in some places. Maybe I'm passing the parameters incorrectly? Or is there a better way to get just the year without any extra complications?
I've also heard that you can use DateTime objects, but I don't yet understand how they are better than simple date(). Please tell me how to correctly and reliably get the current year in PHP so that the code works on any server and doesn't depend on locale settings. I will be