Jump to content


Photo

[solved]timestamp quistion


  • Please log in to reply
11 replies to this topic

#1 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 15 August 2006 - 11:16 AM

if i add the timestamp to the database and put it under date but a time stamp

what command do you use to get it in the database as the time stamp.

example

$date=date("y-m-d");
$date_know=strtotime($date);

echo $date;
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 15 August 2006 - 11:20 AM

If the database field definition is DATE use date

If the database field definition is DATETIME use time stamp

Not sure if that actually answers the question ... ?
Legend has it that reading the manual never killed anyone.
My site

#3 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 15 August 2006 - 11:22 AM

say you want to enter in the database the date for today but you want the database to have it in the format of a time stamp how cheers.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 15 August 2006 - 11:23 AM

Do you mean a unix timestamp? A unix timestamp returns the number of secounds since Jan 1st 1970. if you want to convert a date into a unix timestamp use strtotime function:
$date = "25-12-2006";

// conver the date above into unix timestamp
// which is 1167004800
$timestamp = strtotime($date);

// convert it back into a date
echo date("d - m - y", $timestamp);

or use the time() function to get the unix timestamp of now.

I use INT as the data type for storing timestamps.

#5 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 15 August 2006 - 11:24 AM

thanks wildteens will do tell you how i go cheers mate.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#6 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 15 August 2006 - 11:54 AM

i am so confused when i turn the timestamp back i get 01-01-70 should be 15-08-06

what am i doing wrong please cheers.


<?php

$date=date("d-m-y");

//echo $date;//15-08-06

$date_know=strtotime($date);

//echo $date_know;//1438815600 is the time stamp.

$timestamp_result=date("d-m-y",$dateknow);

echo $timestamp_result;//i get this why? 01-01-70

?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#7 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 15 August 2006 - 11:59 AM

$timestamp_result=date("d-m-y",$dateknow);

should be:

$timestamp_result=date("d-m-y",$date_know);
Legend has it that reading the manual never killed anyone.
My site

#8 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 15 August 2006 - 12:02 PM

didnt see that cheers what an ?????

thank you .

one last quistion what does int stand for ?
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#9 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 15 August 2006 - 12:06 PM

integer range of long numbers i think.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#10 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 15 August 2006 - 12:22 PM

why dosent windows like the code got this error

Warning: date(): Windows does not support dates prior to
midnight (00:00:00), January 1, 1970


pleae tell me cheers.


<?php

//time stamp for one month foward.


$timestamp_one_month_foward="262974383";

//time currently plus time stamp for 1 month.


$date=("d-m-y")+$timestamp_one_month_foward;


// convert date into the unix timestamp


$date_timestamp=strtotime($date);


// get current date what should be 1 month foward. 


$result=date("d-m-y",$date_timestamp);


echo $result;


?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#11 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 15 August 2006 - 12:26 PM

From the date() page of the php manual ... the answer is that Jan 1/70 is the beginning of time.

Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)


As long as Barand and me (and a few others) stay away, that won't matter  :o
Legend has it that reading the manual never killed anyone.
My site

#12 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 15 August 2006 - 12:35 PM

lol that funny

does this look ok and correct  it dispalys correctl but is it a proper programming way

please and cheers.


<?php
// 1 month in front of current date.

$m=date("m")+1;

// current date.

$date=date("d-$m-y");

// current date in a time stamp

$date_timestamp=strtotime($date);

echo "<br>This is the time stamp one month foward:$date_timestamp<br>";

$result=date("d-m-y",$date_timestamp);

echo "<br>This is the readable result:$result<br>";
?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users