Strict Standards: Non-static method Advanced_Permalinks::get() should not be called statically in /blog/wp-content/plugins/advanced-permalinks/advanced-permalinks.php on line 825

Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method GoogleSitemapGeneratorLoader::Enable() should not be called statically in /blog/wp-includes/plugin.php on line 123

Warning: call_user_func_array() expects parameter 2 to be array, null given in /blog/wp-includes/plugin.php on line 123
[PHP] Operacje na datach pobieranych z formularzy w formacie RRRR-MM-DD » Porady PHP » egrafik.pl
BAZA WIEDZY
KURSY
Bazy danych w PHP
Kurs AdvancedAJAX
Kurs ASP
Kurs ASP.NET
Kurs C++
Kurs CSS
Kurs HTML
Kurs HTML drugi
Kurs JavaScript
Kurs MySQL
Kurs PHP
Kurs RSS
Kurs XHTML
Obiekty DOM
MANUALE
CSS1 - W3C
DOM - w budowie
PHP 2005
PHP 2006
Wyrażenia regularne
SHOUTBOX
STAT
Online: 14 | UU: 489

Strict Standards: Resource ID#196 used as offset, casting to integer (196) in /forum2/db/mysql4.php on line 223

Strict Standards: Resource ID#196 used as offset, casting to integer (196) in /forum2/db/mysql4.php on line 224
[PHP] Operacje na datach pobieranych z formularzy w formacie RRRR-MM-DD
Porady PHP | 16 luty 2009 | Wizyt: 106409

Strict Standards: Only variables should be assigned by reference in /blog/wp-includes/post.php on line 114

Strict Standards: Only variables should be assigned by reference in /blog/wp-includes/post.php on line 114

Strict Standards: Only variables should be assigned by reference in /blog/wp-includes/post.php on line 114

Strict Standards: Only variables should be assigned by reference in /blog/wp-includes/post.php on line 114

Strict Standards: Only variables should be assigned by reference in /blog/wp-includes/post.php on line 114

Strict Standards: Only variables should be assigned by reference in /blog/wp-includes/post.php on line 114

Strict Standards: Only variables should be assigned by reference in /blog/wp-includes/post.php on line 114

Strict Standards: Only variables should be assigned by reference in /blog/wp-includes/post.php on line 114

Deprecated: Function eregi() is deprecated in /blog/wp-content/plugins/tpbc.php on line 96

W tej poradzie przedstawię kilka operacji na datach w formacie RRRR-MM-DD. Taki format może być np. pobierany z formularzy podczas podawania daty urodzenia.

Przykład:

Kod: php

<?php
$data_urodz = ‘1981-03-04′;
$data_obecna = date("Y-m-d");
$data_urodz_unix = strtotime($data_urodz);
$data_obecna_unix = strtotime($data_obecna);

$roznica_lata = ($data_obecna_unix - $data_urodz_unix) / (60*60*24*365.25);
$roznica_dni = ($data_obecna_unix - $data_urodz_unix) / (60*60*24);
$roznica_godziny = ($data_obecna_unix - $data_urodz_unix) / (60*60);
$roznica_minuty = ($data_obecna_unix - $data_urodz_unix) / (60);

echo "Minely ".$roznica_lata." lata od daty Twoich urodzin <br />";
echo "Minely ".$roznica_dni." dni od daty Twoich urodzin <br />";
echo "Minely ".$roznica_godziny." godziny od daty Twoich urodzin <br />";
echo "Minely ".$roznica_minuty." minuty od daty Twoich urodzin <br />";
?>

Pod zmienną $data_urodz możesz podstawić swoją datę urodzenia, a poznasz kilka ciekawych faktów.

Autor: Adam Suchowski

nowe Porady PHP » zobacz wszystkie
Dodaj komentarz









Komentarze
2 odpowiedzi
xxx
25 marzec 2017, godz. 8:52

I blog quite often and I really appreciate your information. This article has really peaked my interest.
I am going to book mark your website and keep checking for new details about once per week.

I opted in for your RSS feed as well.

10 styczeń 2016, godz. 8:57

naturally like your web site however you need to test the spelling on quite a few
of your posts. A number of them are rife with spelling problems and I in finding it very troublesome to tell the reality then again I will certainly come
again again.

 
| | | |
Copyright © 2006-2013 egrafik.pl | Kontakt | Reklama | Projekty domów
jocker