Skip to content

Instantly share code, notes, and snippets.

@sergejmueller
Created May 31, 2012 12:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sergejmueller/2842988 to your computer and use it in GitHub Desktop.
Save sergejmueller/2842988 to your computer and use it in GitHub Desktop.
Korrekte Ermittlung des letzten Monats am 31. eines Monats. Nur für PHP 5.3.
<?php
/* Heute ist der 31. Mai */
$t = strtotime('-1 month');
echo strftime('%e. %B', $t);
// Ausgabe: 1. May
$t = strtotime('first day of previous month');
echo strftime('%e. %B', $t);
// Ausgabe: 1. April
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment