Home / Tips / Programming languages / Scripting languages / PHP / Converting date to Unix timestamp using PHP

Converting date to Unix timestamp using PHP

PHP
 
PHP
  • Currently 0 out of 5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Rating: 0/5 (0 votes cast)

Thank you for rating!

You have already rated this page, you can only rate it once!

Your rating has been changed, thanks for rating!

Log in or create a user account to rate this page.


This can be simply done by the PHP function strtotime.

Here are two examples of dates with time and without it:

$timestampDate = strtotime( '29-04-2009' );
$timestampDateAndTime = strtotime( '29.04.2009 23:42:26' );

echo( date( 'l jS \of F Y h:i:s A', $timestampDate ) );
echo( '<br />' );
echo( date( 'l jS \of F Y h:i:s A', $timestampDateAndTime ) );

Result:

Wednesday 29th of April 2009 12:00:00 AM
Wednesday 29th of April 2009 11:42:26 PM

 

Read also

What is PHP?

What is PHP?

Classes and objects in PHP

Classes and objects in PHP

How to access classes and objects in PHP

How to access classes and objects in PHP

Post comment

basicuse.net
html5_css
106160485398655174790

Quick navigation

General navigation