Time Stamp Help

Reply

Join Date: Jan 2008
Posts: 19
Reputation: Morty222 is an unknown quantity at this point 
Solved Threads: 0
Morty222 Morty222 is offline Offline
Newbie Poster

Time Stamp Help

 
0
  #1
Mar 5th, 2008
I am using current_timestamp and it works great but when I output the data onto a php page it looks like this:

2008-03-05 18:05:44

Anyone know how I can make it look like this?

03-05-2008 18:05:44
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 9
Reputation: fert is an unknown quantity at this point 
Solved Threads: 1
fert's Avatar
fert fert is offline Offline
Newbie Poster

Re: Time Stamp Help

 
0
  #2
Mar 6th, 2008
Use the date() function: http://php.net/date

  1. $time = time();
  2. $date = date('d-m-L H:i:s' , $time);
  3.  
  4. echo $date; // 03-05-2008 18:05:44
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 561
Reputation: ryan_vietnow is an unknown quantity at this point 
Solved Threads: 71
ryan_vietnow's Avatar
ryan_vietnow ryan_vietnow is offline Offline
Posting Pro

Re: Time Stamp Help

 
0
  #3
Mar 6th, 2008
Here,I made a function just for you using explode function:

  1. //$var is your timestamp...
  2. function x($var)
  3. {
  4. list($date,$time)=explode(" ", $var);
  5. list($year,$month,$day)=explode("-",$date);
  6. $newdate=$month."-".$day."-".$year." ".$time;
  7. return $newdate;
  8. }

Enjoy!!!
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 84
Reputation: johnsquibb is an unknown quantity at this point 
Solved Threads: 14
johnsquibb's Avatar
johnsquibb johnsquibb is offline Offline
Junior Poster in Training

Re: Time Stamp Help

 
0
  #4
Mar 6th, 2008
  1. <?php
  2.  
  3. //old time
  4. $old_time = '2008-03-05 18:05:44';
  5.  
  6. //convert to UNIX timestamp
  7. $timestamp = strtotime($old_time);
  8.  
  9. //fetch new format
  10. $new_time = date('m-d-Y H:i:s' , $timestamp);
  11.  
  12. //output new time
  13. echo $new_time;
  14. ?>
The End
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 84
Reputation: johnsquibb is an unknown quantity at this point 
Solved Threads: 14
johnsquibb's Avatar
johnsquibb johnsquibb is offline Offline
Junior Poster in Training

Re: Time Stamp Help

 
0
  #5
Mar 6th, 2008
Originally Posted by fert View Post
Use the date() function: http://php.net/date

  1. $time = time();
  2. $date = date('d-m-L H:i:s' , $time);
  3.  
  4. echo $date; // 03-05-2008 18:05:44
'L' returns 1 if it is a leap year or 0 if it is not. Use 'Y' for 4-digit year.
The End
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC