1 / 4

Understanding PHP Date Functions and Formatting Examples

This guide provides an overview of PHP date functions, including how to construct and format dates. It explains the usage of the `echo date()` function, demonstrating various formatting options such as day, month, and year outputs in different styles. The tutorial also introduces the `getdate()` function, which returns an array with comprehensive date and time information based on a Unix timestamp. Practical examples illustrate how to manipulate and present dates in PHP effectively, catering to both beginners and experienced developers.

vinaya
Télécharger la présentation

Understanding PHP Date Functions and Formatting Examples

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Funzioni date ed orari

  2. date • Costruire una data • echo date ("d/m/Y"); 23/01/2012 • echo date("d-m-Y"); 23-01-2012 • echo date("m-M"); 01-Jan • echo date("m-M-F");01-Jan-January • echo date("d-D-l");23-Mon-Monday • echo date("Y-y");2012-12 • echo date("H:i:s");20-52-22 • echo date("z");20 giorni trascorsi dall’inizio dell’anno

  3. Funzione getdate() • The getdate() function returns an array that contains date and time information for a Unix timestamp. • The returning array contains ten elements with relevant information needed when formatting a date string: • [seconds] – seconds [minutes] – minutes [hours] – hours [mday] - day of the mont [wday] - day of the week [year] – year [yday] - day of the year [weekday] - name of the weekday [month] - name of the month • Sintassi • getdate(timestamp) Vai alla diapositiva successiva per l’esempio

  4. Example 1 • <?phpprint_r(getdate());?>The output of the code above could be: • Array([seconds] => 45[minutes] => 52[hours] => 14[mday] => 24[wday] => 2[mon] => 1[year] => 2006[yday] => 23[weekday] => Tuesday[month] => January[0] => 1138110765) • Example 2 • <?php$my_t=getdate(date("U"));print("$my_t[weekday], $my_t[month] $my_t[mday], $my_t[year]");?>The output of the code above could be: • Wednesday, January 25, 2006

More Related