以下是一个PHP实例,展示如何将日期格式化为“年 月”格式。

```php

// 设置日期

$date = new DateTime();

// 获取年月格式的日期

$yearMonth = $date->format('Y年m月');

// 输出结果

echo "