Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,864 questions

51,786 answers

573 users

How to use idate() function to format a local date/time using integer timestamp in PHP

1 Answer

0 votes
// int idate(string $format [, int $timestamp]);

$timestamp = strtotime('23st March 2016');
   
echo 'y - ' . idate('y', $timestamp) . "<br />";  // Year (1 or 2 digits)

echo 'Y - ' . idate('Y', $timestamp) . "<br />";  // Year (4 digits)

echo 'd - ' . idate('d', $timestamp) . "<br />";  // Day of the month

echo 'h - ' . idate('h', $timestamp) . "<br />";  // Hour (12 hour format)

echo 'i - ' . idate('i', $timestamp) . "<br />";  // Minutes
   
echo 't - ' . idate('t', $timestamp) . "<br />";  // Days in current month

echo 'w - ' . idate('w', $timestamp) . "<br />";  // Day of the week (Sunday = 0)

echo 'z - ' . idate('z', $timestamp) . "<br />";  // Day of the year

/*
run:

y - 16
Y - 2016
d - 23
h - 12
i - 0
t - 31
w - 3
z - 82
       
*/

 



answered Mar 23, 2016 by avibootz
...