Kracker Posted January 13, 2013 Report Share Posted January 13, 2013 Sveiki! Vai kāds zin variantu, kā varētu piemēram pie šī 10.11.2012 pieskaitīt 60 dienas un beigu beigās izvada datumu reālo, kas būtu pēc 60 dienu skaita? p.s. vajadzētu uzrādīt datumu pašreizējā variantā 10.01.2013. Paldies! Quote Link to comment Share on other sites More sharing options...
marrtins Posted January 13, 2013 Report Share Posted January 13, 2013 echo date('d.m.Y', strtotime('10.11.2012 + 60 days')); Quote Link to comment Share on other sites More sharing options...
Kracker Posted February 13, 2013 Author Report Share Posted February 13, 2013 Paldies! Quote Link to comment Share on other sites More sharing options...
martins256 Posted February 13, 2013 Report Share Posted February 13, 2013 Rezultātā jāiegūst 09.01.2013 nevis 10.01.2013. Man daudz labāk patīk DateTime objekti nekā String tipa mainīgie. echo DateTime::createFromFormat('d.m.Y', '10.11.2012')->add(new DateInterval('P60D'))->format('d.m.Y'); Quote Link to comment Share on other sites More sharing options...
aaxc Posted February 13, 2013 Report Share Posted February 13, 2013 DateTime::createFromFormat PHP 5 >= 5.3.0 Daudzas sistēmas vēljoprojām sēž uz 5.2.9 Quote Link to comment Share on other sites More sharing options...
martins256 Posted February 14, 2013 Report Share Posted February 14, 2013 Piedāvāju tad php 5.4 risinājumu echo (new DateTime('10.11.2012'))->add(new DateInterval('P60D'))->format('d.m.Y'); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.