Jump to content

[SOLVED] Date times....


phpSensei

Recommended Posts

I have a little question...

 

Can I use the SELECT statement, and Display all my data from a certain table depending on the date?

 

If the date is newer then it will show that id, within the table?

 

Any of this possible?

 

I was thinking of this

 


<?php

$sql="SELECT * FROM table_1 ORDER BY date ASC";
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
?>

Link to comment
https://forums.phpfreaks.com/topic/60075-solved-date-times/
Share on other sites

Exactly how you resolve it depends on what format you've used for 'date' in your database. The date() function along with the strtotime() or mktime() functions ought to be able to handle most of what you need.

 

list($y,$m,$d) = explode("-",date("Y-m-d"));// today
$month_ago = date("Y-m-d", mktime(0,0,0,$m-1,$d,$y));

Link to comment
https://forums.phpfreaks.com/topic/60075-solved-date-times/#findComment-298815
Share on other sites

Exactly how you resolve it depends on what format you've used for 'date' in your database. The date() function along with the strtotime() or mktime() functions ought to be able to handle most of what you need.

 

list($y,$m,$d) = explode("-",date("Y-m-d"));// today
$month_ago = date("Y-m-d", mktime(0,0,0,$m-1,$d,$y));

 

Thankyou so much, My forum is done with everything.

 

This was the only thing left.

Link to comment
https://forums.phpfreaks.com/topic/60075-solved-date-times/#findComment-298819
Share on other sites

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.