-
Notifications
You must be signed in to change notification settings - Fork 0
/
datecreate.php
53 lines (35 loc) · 1.46 KB
/
datecreate.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
define('ENABLE_TEST_VARIABLES',FALSE);
/**
@addition - the Unix timestamp increases by 86,400 seconds each day
@description - so to figure out what the timestamp will be five days in the future we have 86,400x
*/
/**
@method strtotime
*/
$was_dir = getcwd();
chdir('\inetpub\ocdla');
require('sql_conn4.php');
chdir($was_dir);
$product_query = "SELECT * FROM catalog WHERE i=923";
$product_resource = mysql_query( $product_query );
$this_product = mysql_fetch_assoc( $product_resource );
$datetime = date_create();
echo "<h2>Standard date from MySQL date field:</h2> <p>{$this_product['ReadyDate']}</p>";
echo "<h2>Array produced from <i>getdate()</i></h2><p>".print_r( getdate() )."</p>";
$past_date = date_create($this_product['ReadyDate'].' 00:00:00');
if( date_create() < $past_date ) echo "Today is greater than the past date.";
print_r( $past_date );
echo "<p>**********</p>";
$times = array();
$times[] = strtotime( $this_product['ReadyDate'] );
$times[] = strtotime( '2010-04-25 00:00:21' );
$ready_date = getdate( $times[0] );
$ready_month = $ready_date["month"];
$ready_day = $ready_date["mday"];
$ready_year = $ready_date["year"];
foreach( $times AS $timestamp ) echo "<h2>$timestamp</h2>";
echo "<h1>$ready_month $ready_day, $ready_year</h1>";
echo "<h1>Example using strtotime to get the timestamp from a 2010-01-01-style date and formatting the date using date()</h1>";
echo "<p style='color:red;'>".date('F j, Y',strtotime('2010-04-25'))."</p>";
?>