I want to get the yesterday date using specific date format in php this is the format:
$today = date("d.m.Y"); //15.04.2013
Is it possible?
Take consideration of month and years if they should be changed in respective.
You can simply use the PHP date() function to get the current data and time in various format, for example, date('d-m-y h:i:s') , date('d/m/y H:i:s') , and so on.
$newDate = date('Y-m-d', strtotime('tomorrow')); echo $newDate; ?>
The strtotime() function parses an English textual datetime into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 GMT). Note: If the year is specified in a two-digit format, values between 0-69 are mapped to 2000-2069 and values between 70-100 are mapped to 1970-2000.
there you go
date('d.m.Y',strtotime("-1 days"));
this will work also if month change
try this
$tz = new DateTimeZone('Your Time Zone'); $date = new DateTime($today,$tz); $interval = new DateInterval('P1D'); $date->sub($interval); echo $date->format('d.m.y'); ?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With