date() और time() इस दो function से date और time को output में display किया जाता है |
Current Date/Time
Syntax for date/time()
date(date_format, timestamp);
date_format : यहाँ पर date का format दिया जाता है | ये current date print करता है | ये timestamp को date/time format में convert कर देता है |
timestamp : यहाँ पर ये optional रहता है | अगर कोई value दी नहीं जाती तो current timestamp दिया जाता है |
Additional formatting के लिए date में /, :, - का इस्तेमाल किया जाता है |
Example for date()
Source Code :Output :123456<?php
echo "Current Date : ".date("d/m/y")."<br />";
echo "Current Time : ".date("H:i:sa")."<br />";
echo "Current Day : ".date("l")."<br />";
echo "Current Month : ".date("M")."<br />";
?>
Current Date : 19/02/17
Current Time : 15:54:08pm
Current Day : Sunday
Current Month : Feb
Timestamp
Timestamp ये readable नहीं होता इसे समझने के लिए date() function का इस्तेमाल करना पड़ता है |
Timestamp में time() function का इस्तेमाल किया जाता है |
यहाँ पर 1 January 1970 00:00 से लेकर अभी इसी वक्त तक seconds display होते है |
Example for time()
Source Code :Output :123<?php
echo "Current Timestamp : ".time();
?>
Current Timestamp : 1487518199
Table for Date Formats
| Format | Description | Example |
|---|---|---|
| a | 'am' या 'pm' lowercase | am |
| A | 'AM' या 'PM' uppercase | AM |
| d | शुरुआत में 0 के साथ 2 digits के month का day 01 से 31 तक | 15 |
| D | 3 letters week का day | Mon |
| F | month का full name | March |
| g | शुरुआत से 0 के बिना hour के लिए 12hour का format 1 से 12 तक | 5 |
| G | शुरुआत से 0 के बिना hour के लिए 24hour का format 0 से 23 तक | 3 |
| h | शुरुआत से 0 के साथ 12hour के format में hour 01 से 12 तक | 05 |
| H | शुरुआत से 0 के साथ 24hour के format में hour 00 से 24 तक | 00 |
| i | शुरुआत से 0 के साथ minutes 00 से 59 तक | 58 |
| I | अगर Daylight Savings Time है तो 1 नहीं तो 0 | 1 |
| j | शुरुआत से 0 के बिना month का day 1 से 31 तक | 27 |
| l | Week का day full name | Friday |
| L | Leap year है तो 1 नहीं तो 0 | 0 |
| m | शुरुआत से 0 के साथ year का month 01 से 12 तक | 02 |
| M | 3 letters year का month | Jun |
| n | शुरुआत से 0 के बिना year का month 1 से 12 तक | 10 |
| r | RFC 822 formatted date | Sun, 19 Feb 2017 19:07:40 +0100 |
| s | seconds 00 से 59 तक | 58 |
| t | check month के days 28 से 31 तक | 31 |
| U | timestamp | 1487527863 |
| y | 2 digits year | 17 |
| Y | 4 digits year | 2017 |
| z | year का day 0 से 365 तक | 106 |
| Z | timezone offset seconds में | 3600 |
0 comments:
Post a Comment
Thanks