Jump to content

[solved]timestamp quistion


redarrow

Recommended Posts

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:
[code=php:0]$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);[/code]

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

I use INT as the data type for storing timestamps.
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.

[code]

<?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

?>
[/code]
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.


[code]
<?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;


?>
[/code]
lol that funny

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

please and cheers.


[code]
<?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>";
?>
[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.