Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 132,368 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,318 people online right now. Registration is fast and FREE... Join Now!




timestamp

 
Reply to this topicStart new topic

timestamp

iamcenz
post 9 Dec, 2002 - 10:09 PM
Post #1


You wish you were my hand!

Group Icon
Joined: 26 Mar, 2001
Posts: 2,385



Dream Kudos: 201
My Contributions


how do you do a timestamp, cause im working on trying to make a news script system/blog system and i need a timestamp date and time, how would i do this?
User is offlineProfile CardPM

Go to the top of the page

skyhawk133
post 10 Dec, 2002 - 12:39 AM
Post #2


Head DIC Head

Group Icon
Joined: 17 Mar, 2001
Posts: 14,844



Thanked 45 times

Dream Kudos: 1650

Expert In: Web Development

My Contributions


mySQL has a timestamp thingy built into it that will auto timestamp using the unix time format.

Then you can use like strtotime($variable) then use the $date() function
User is offlineProfile CardPM

Go to the top of the page

iamcenz
post 10 Dec, 2002 - 08:14 PM
Post #3


You wish you were my hand!

Group Icon
Joined: 26 Mar, 2001
Posts: 2,385



Dream Kudos: 201
My Contributions


can you explain how to use this in more detail. im alittle lost.
User is offlineProfile CardPM

Go to the top of the page

arniie
post 11 Dec, 2002 - 01:18 AM
Post #4


D.I.C Addict

****
Joined: 8 Oct, 2002
Posts: 999

just set a field in your database to type: timestamp

you ca nthen use php functions to retrieve this date in a readable format

theres lots of different and better ways than this...but to quickly show you
a way...(This is mucky quick fix way)

SELECT STATEMENT TO FIND TIMESTAMP FIELD
$result = mysql_query($query, $connection);
$row = mysql_fetch_array($result)


$sTime = $row[field];

$sYear = substr($sTime, 0, 4);
$sMonth = substr($sTime, 4, 2);
$sDay = substr($sTime, 6, 2 );
$sTimeH = substr($sTime, 8, 2);
$sTimeM = substr($sTime, 10, 2);
$sTimeS = substr($sTime, -2);
User is offlineProfile CardPM

Go to the top of the page

iamcenz
post 11 Dec, 2002 - 12:43 PM
Post #5


You wish you were my hand!

Group Icon
Joined: 26 Mar, 2001
Posts: 2,385



Dream Kudos: 201
My Contributions


im getting this
QUOTE
posted by Vinny on 20021211152253
how would i format that?
User is offlineProfile CardPM

Go to the top of the page

arniie
post 11 Dec, 2002 - 01:06 PM
Post #6


D.I.C Addict

****
Joined: 8 Oct, 2002
Posts: 999

i just showed you

use the function substr

say you want the year 2002

use:

$Year = substr($sTime, 0, 4);

if you want the day use

$Day = substr($sTime, 6, 2 );

ok?
User is offlineProfile CardPM

Go to the top of the page

iamcenz
post 11 Dec, 2002 - 01:12 PM
Post #7


You wish you were my hand!

Group Icon
Joined: 26 Mar, 2001
Posts: 2,385



Dream Kudos: 201
My Contributions


what does the 0,4 mean and the 2,6
User is offlineProfile CardPM

Go to the top of the page

MathewS
post 16 Dec, 2002 - 08:10 AM
Post #8


D.I.C Regular

***
Joined: 14 May, 2002
Posts: 252



Thanked 1 times

Dream Kudos: 1
My Contributions


to display the date of a time stamp use

CODE


function time_format($timestamp)
{
   $hour = substr($timestamp,8,2);  
   $minute = substr($timestamp,10,2);  
   $second = substr($timestamp,12,2);  
   $month = substr($timestamp,4,2);  
   $day = substr($timestamp,6,2);  
   $year = substr($timestamp,0,4);  
   $mktime = mktime($hour, $minute, $second, $month, $day, $year);  
   $formated = date("F j, Y, g:i a",$mktime);
   return $formated;
}


then simply call it using

CODE

time_format($row[timestamp]);
User is offlineProfile CardPM

Go to the top of the page

gneato
post 16 Dec, 2002 - 09:28 AM
Post #9


<title>Untitled Document</title>

*****
Joined: 3 Sep, 2001
Posts: 1,311

Goofballs.

http://www.php.net/manual/en/function.strftime.php
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/22/08 05:14AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month