KillerBean Posted March 10, 2007 Report Share Posted March 10, 2007 (edited) Sveiki. Gribeeju apjautaaties vai nav kaadas PHP komandas kas peec ievadiitaa datuma atgriezh datumu, peec noraadiita dienu skaita? vai ar mkdate() to var izdariit?? piem.: $new_date = ievad.datums + 1 nedeelja.. vai arii ir jaapaarveido datumi uz dienas skaitu, gadaa... un jaapieskaita 7? Edited March 10, 2007 by KillerBean Link to comment Share on other sites More sharing options...
ohmygod Posted March 10, 2007 Report Share Posted March 10, 2007 php.net. mktime funkcija. 3 piemērs, vēl pat neiebraucot user notēs. Tu dokumentāciju lasi, pirms prasi kaut ko vispār? <?php $tomorrow = mktime(0, 0, 0, date("m") , date("d")+1, date("Y")); $lastmonth = mktime(0, 0, 0, date("m")-1, date("d"), date("Y")); $nextyear = mktime(0, 0, 0, date("m"), date("d"), date("Y")+1); ?> Link to comment Share on other sites More sharing options...
andrisp Posted March 10, 2007 Report Share Posted March 10, 2007 Izmanto php.net/strtotime, lai dabūtu unix timestamp un tad pieskaiti 7 * tik_cik_sekundes_dienaa (slinkums tagad rakstīt :)). Un tad php.net/date dabū atpakaļ normālu formātu. Btw, ja datumu ņem no mysql, tad tur ir tādas fjas kād DATE_ADD un DATE_SUB, ja nemaldos. Link to comment Share on other sites More sharing options...
Stopp Posted March 10, 2007 Report Share Posted March 10, 2007 andrisp, wtf? Kāpēc strtotime un vēl pieskaitīt 7 dienas sekundēs? strtotime jau var uztaisīt vienu nedēļu plusos. Link to comment Share on other sites More sharing options...
andrisp Posted March 10, 2007 Report Share Posted March 10, 2007 Ā, nu jā. Link to comment Share on other sites More sharing options...
andrisp Posted March 10, 2007 Report Share Posted March 10, 2007 Stopp, pag, paskaidro savu domu sīkāk. Es īsti neiebraucu. Link to comment Share on other sites More sharing options...
Val Posted March 10, 2007 Report Share Posted March 10, 2007 Liekas, ka šito bija Stopp domājis: strtotime("+1 week") Link to comment Share on other sites More sharing options...
andrisp Posted March 11, 2007 Report Share Posted March 11, 2007 Jā, bet vai tas atrisina autora problēmu ? Link to comment Share on other sites More sharing options...
Stopp Posted March 11, 2007 Report Share Posted March 11, 2007 Nē, es vienkārši nesaprotu, kāpēc tu saki, lai ar strorime dabū timestampu. Lai dabūtu timestamp no kaut kāda ievadītā datuma, jāizmanto mktime takš. Link to comment Share on other sites More sharing options...
andrisp Posted March 11, 2007 Report Share Posted March 11, 2007 Un kāpēc nevar izmantot php.net/strtotime ? strtotime un mktime ir divas diezgan atšķirīgas fjas. Link to comment Share on other sites More sharing options...
Stopp Posted March 11, 2007 Report Share Posted March 11, 2007 (edited) -- neko :) Edited March 11, 2007 by Stopp Link to comment Share on other sites More sharing options...
Recommended Posts