...

View Full Version : Converting Time in PHP



bradwbowman
07-02-2007, 11:14 AM
I have an application that gives me numbers like 1183354915 and the php coding converts it into a time.

print date('d m Y', $row['topic_time']);


Are there any converters that will allow me to input July 2, 10:59PM and it will spit out that number?

Thank You,
Brad C
www.clicknowdomains.com

Iszak
07-02-2007, 12:01 PM
Yes, you can! I would suggest reading the manual first.. but I mean there are so
many functions so I don't blame you.. anyhow this is how to do it..



<?php
$string = "July 2, 10:59PM";
echo strtotime($string);
?>


OR...



<?php
echo strtotime("July 2, 10:59PM");
?>


and forgot output.. this is what it'll output "1183417140" :D

Enjoy! :D

bradwbowman
07-02-2007, 07:04 PM
All this does it provides the output of "-1" Am I missing something?

Thank You,
Brad

Iszak
07-03-2007, 10:18 AM
You must be, because it outputs exactly as I put it in both examples.

VBAssassin
07-03-2007, 10:35 AM
Just so you no, there is another function quite useful in generating time stamps:

mktime();

Look it up on php.net



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum