 [ ← blog / php ](/) Jun 27, 2011  ·  \#php  ·  1 min read 

# DateFormat PHP Class



 DateFormat is a PHP class for easily displaying timestamps in a PHP project, along with displaying a "time since" feature, much like the one used on Facebook and other sites. A  demo of the class is available in my script playground:  [glamanate.com/playground/DateFormat/](http://glamanate.com/playground/DateFormat/). 

## **DateFormat Class Documentation**

**Initialize Class**

> ```
> $date = new FormatDate(time());
> ```

**Numerical Day**

> ```
> $date->Day();
> ```

**Text Day**

> ```
> $date->WeekDay();
> ```

**Month (Full)**

> ```
> $date->Month();
> ```

**Month (Short)**

> ```
> $date->MonthShort();
> ```

**Month (Numerical)**

> ```
> $date->MonthNum();
> ```

**Year (Full)**

> ```
> $date->YearFull();
> ```

**Year (Short)**

> ```
> $date->Year();
> ```

**Military (Seconds)**

> ```
> $date->MilitaryFull();
> ```

**Military (No seconds)**

> ```
> $date->Military();
> ```

**Standard (Full)**

> ```
> $date->StandardFull();
> ```

**Standard**

> ```
> $date->Standard();
> ```

**Text Date (Full)**

> ```
> $date->TextDate();
> ```

**Text Date (Short)**

> ```
> $date->TextDateShort();
> ```

**Numerical Date (Full)**

> ```
> $date->NumDate();
> ```

**Numerical Date (Short)**

> ```
> $date->NumDateShort();
> ```

**Month and Day (Full)**

> ```
> $date->MonthDay();
> ```

**Month and Day (Short)**

> ```
> $date->MonthDayShort();
> ```

**Time Since**

> ```
> $date->TimeSince($timestamp);
> ```

 

  ![](/themes/custom/mglaman/images/headshot.webp)Thanks for reading

I write about Drupal, PHP, and the quiet infrastructure behind large sites — caching, config, and testing. New posts land every week or two.

 [Subscribe via RSS →](/rss.xml) [About me →](/about-me) 

 



 

  [← Older

Samsara Laser Hair Removal

 ](/blog/samsara-laser-hair-removal) [Newer →

jQuery Contact Form

 ](/blog/jquery-contact-form)