klavsr Posted June 22, 2010 Report Share Posted June 22, 2010 Atņemot no nākotnes timestamp šībrīža timestamp, tiek iegūts laiks kas atlicis līdz kaut kādam notikumam. Piemēram "2585711" sekundes. Kā to viegli pārsvērst formātā 29 dienas, XX stundas un XX minūtes? Mēģināju date('d \d\i\e\n\a\s, H \s\t\u\n\d\a\s \u\n i \m\i\n\ū\t\e\s', 2585711) bet šis rāda 31 dienas, 00 stundas un 15 minūtes Quote Link to comment Share on other sites More sharing options...
briedis Posted June 22, 2010 Report Share Posted June 22, 2010 Parasta matemātika. Dali, reizini, atņem... Taču zini, cik vienā dienā ir sekundes? Nu tad arī izdali sekundes ar dienu sekunžu skaitu, saskaiti cik dienas, dabū atlikumu, tad dali ar stundām, minūtēm.... Tīra 3. klasītes matemātika... Quote Link to comment Share on other sites More sharing options...
Леший Posted June 22, 2010 Report Share Posted June 22, 2010 $days = floor($x/86400); $rem = $x % 86400; $hours = floor($rem/3600); $rem = $rem % 3600; $minutes = floor($rem/60); Quote Link to comment Share on other sites More sharing options...
klavsr Posted June 22, 2010 Author Report Share Posted June 22, 2010 Paldies! Šādi arī darīju. Domāju tik, vai nav kāds īsāks variants. 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.