Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-02-2007, 10:14 AM   PM User | #1
bradwbowman
New to the CF scene

 
Join Date: Nov 2006
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
bradwbowman is an unknown quantity at this point
Converting Time in PHP

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
bradwbowman is offline   Reply With Quote
Old 07-02-2007, 11:01 AM   PM User | #2
Iszak
Regular Coder

 
Iszak's Avatar
 
Join Date: Jun 2007
Location: Perth, Western Australia
Posts: 332
Thanks: 2
Thanked 58 Times in 57 Posts
Iszak is an unknown quantity at this point
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 Code:
<?php
$string 
"July 2, 10:59PM";
echo 
strtotime($string);
?>
OR...

PHP Code:
<?php
echo strtotime("July 2, 10:59PM");
?>
and forgot output.. this is what it'll output "1183417140"

Enjoy!

Last edited by Iszak; 07-02-2007 at 11:02 AM.. Reason: Forgot Output!
Iszak is offline   Reply With Quote
Old 07-02-2007, 06:04 PM   PM User | #3
bradwbowman
New to the CF scene

 
Join Date: Nov 2006
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
bradwbowman is an unknown quantity at this point
All this does it provides the output of "-1" Am I missing something?

Thank You,
Brad
bradwbowman is offline   Reply With Quote
Old 07-03-2007, 09:18 AM   PM User | #4
Iszak
Regular Coder

 
Iszak's Avatar
 
Join Date: Jun 2007
Location: Perth, Western Australia
Posts: 332
Thanks: 2
Thanked 58 Times in 57 Posts
Iszak is an unknown quantity at this point
You must be, because it outputs exactly as I put it in both examples.
Iszak is offline   Reply With Quote
Old 07-03-2007, 09:35 AM   PM User | #5
VBAssassin
New Coder

 
Join Date: Jan 2006
Location: UK (Britain)
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
VBAssassin is an unknown quantity at this point
Just so you no, there is another function quite useful in generating time stamps:

mktime();

Look it up on php.net
__________________
Checkout my coder profile:
http://www.coderprofile.com/coder/VBAssassin
VBAssassin is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:02 AM.


Advertisement
Log in to turn off these ads.