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.
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

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

[quote]Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)[/quote]

As long as Barand and me (and a few others) stay away, that won't matter  :o
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.