Jump to content

Search the Community

Showing results for tags 'dates'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 4 results

  1. Hello: How could I use php to automatically insert the correct 3 letter month abbreviations and four digit year in the following pdf filenames on the first of each month? (For example "...Feb2015.pdf" then "...Mar2015.pdf" and so on.... <div>Book One: <a href="http://monthlybookfiles.mysite.com/BookOne_Jan2015.pdf">Download Here</a></div> <div>Book Two: <a href="http://monthlybookfiles.mysite.com/BookTwo_Jan2015.pdf">Download Here</a></div> <div>Book Three: <a href="http://monthlybookfiles.mysite.com/BookThree_Jan2015.pdf">Download Here</a> </div> <div>Book Four: <a href="http://monthlybookfiles.mysite.com/BookFour_Jan2015.pdf">Download Here</a> </div> Please advise, Eggie
  2. Hi all, I'm a PHP coder who sucks at date manipulation. Here's the problem: I have code that builds and manipulates a bunch of dates, starting from 2 "main" date values. Then it changes the main dates via date_add & date_sub. It works just fine if all I want to do is print the date values inside a "while" loop. See example here:http://gardencalc.drivingpeace.com/results1.php However, now I need to load everything into an array and pass it to a grid widget. Date_add & date_sub appear to change not only the orginal "main" date values, but also the values of any other variables created from the original date, so all date values become the same. See grid widget example here: http://gardencalc.drivingpeace.com/grid.htm I need to somehow change the dates inside some logic code, capture the saved changes into the array, then pass the array to the widget. Like I said, I suck at date functions, and I need an alternative to date_add, etc. PHP code for the grid widget is below. Any suggestions are most welcome. I imagine there's an easy answer, but I'm stumped! Thanks! <?php $loc_id = 174; $prob_id = 10; #Include the connect.php file include('connect.php'); #Connect to the database //connection String $connect = mysql_connect($hostname, $username, $password) or die('Could not connect: ' . mysql_error()); //select database mysql_select_db($database, $connect); //Select The database $bool = mysql_select_db($database, $connect); if ($bool === False){ print "can't find $database"; } $tempSQL = "SELECT * FROM prob_28 WHERE prob_id=$loc_id"; $temp = mysql_query($tempSQL) or die(mysql_error()); while($row = mysql_fetch_array( $temp )) { $prob1_90 = $row['prob1_90']; $prob1_50 = $row['prob1_50']; $prob1_10 = $row['prob1_10']; $prob2_10 = $row['prob2_10']; $prob2_50 = $row['prob2_50']; $prob2_90 = $row['prob2_90']; } //build the dates if ($prob_id == "10"){ $first_frost_date = date_create(date("Y").'-'.substr($prob1_10,0,2).'-'.substr($prob1_10,2,2)); $last_frost_date = date_create(date("Y").'-'.substr($prob2_10,0,2).'-'.substr($prob2_10,2,2)); }elseif ($prob_id == "50"){ $first_frost_date = date_create(date("Y").'-'.substr($prob1_50,0,2).'-'.substr($prob1_50,2,2)); $last_frost_date = date_create(date("Y").'-'.substr($prob2_50,0,2).'-'.substr($prob2_50,2,2)); }else{ $first_frost_date = date_create(date("Y").'-'.substr($prob1_90,0,2).'-'.substr($prob1_90,2,2)); $last_frost_date = date_create(date("Y").'-'.substr($prob2_90,0,2).'-'.substr($prob2_90,2,2)); } // get data and store in a json array $query = "SELECT * FROM data ORDER BY data_id"; $result = mysql_query($query) or die("SQL Error 1: " . mysql_error()); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $curcrop = array(); $data_id = $row['data_id']; $days_to_harvest = $row['days_2_harvest']; $resolution = $row['resolution']; //Get type name $type_id = $row['type_id']; $type = mysql_query("SELECT * FROM type WHERE type_id=$type_id") or die(mysql_error()); while($typerow = mysql_fetch_array( $type )) { $curcrop['Type'] = $typerow['type_name']; } //Get planting method name $method_id = $row['method_id']; $method = mysql_query("SELECT * FROM method WHERE method_id=$method_id") or die(mysql_error()); while($methodrow = mysql_fetch_array( $method )) { $curcrop['Method'] = $methodrow['method_name']; } //Get crop name $crop_id = $row['crop_id']; $crop = mysql_query("SELECT * FROM crop WHERE crop_id=$crop_id") or die(mysql_error()); while($croprow = mysql_fetch_array( $crop )) { $curcrop['Crop'] = $croprow['crop_name']; } //calculate the direct sow date //Only build real date if the planting method is direct sow if ($method_id == 1){ //check if it's a fall or spring crop type //spring date if ($type_id == 1){ $direct_sow_date = $first_frost_date; $date_int = $row['wks_b4_frost_2_sow'] * 7; date_sub($direct_sow_date,date_interval_create_from_date_string("$date_int days")); //fall date }else{ $direct_sow_date = $last_frost_date; $date_int = $row['wks_b4_first_frost'] * 7; date_sub($direct_sow_date,date_interval_create_from_date_string("$date_int days")); } }else{ $direct_sow_date = null; } $curcrop['SowDirect'] = $direct_sow_date; //calculate transplant date if ($method_id == 2){ //check if it's a fall or spring crop type //spring date if ($type_id == 1){ $transplant_date = $first_frost_date; $date_int = $row['wks_b4_last_frost_2_trans'] * 7; date_sub($transplant_date,date_interval_create_from_date_string("$date_int days")); //fall date }else{ $transplant_date = $last_frost_date; $date_int = $row['wks_b4_first_frost'] * 7; date_sub($transplant_date,date_interval_create_from_date_string("$date_int days")); } }else{ $transplant_date = null; } //transplant sow date if ($transplant_date != null){ $date_int_trans = $row['wks_2_grow_trans'] * 7; date_sub($transplant_date,date_interval_create_from_date_string("$date_int_trans days")); $curcrop['SowTransplant'] = $transplant_date; date_add($transplant_date,date_interval_create_from_date_string("$date_int_trans days")); }else{ $curcrop['SowTransplant'] = null; } $curcrop['Transplant'] = $transplant_date; //begin harvest date if ($method_id == 1 && $direct_sow_date != null){ date_add($direct_sow_date,date_interval_create_from_date_string("$days_to_harvest days")); date_sub($direct_sow_date,date_interval_create_from_date_string("$resolution days")); $curcrop['BeginHarvest'] = $direct_sow_date; date_sub($direct_sow_date,date_interval_create_from_date_string("$days_to_harvest days")); date_add($direct_sow_date,date_interval_create_from_date_string("$resolution days")); } if ($method_id == 2 && $transplant_date != null){ date_add($transplant_date,date_interval_create_from_date_string("$days_to_harvest days")); date_sub($transplant_date,date_interval_create_from_date_string("$resolution days")); $curcrop['BeginHarvest'] = $transplant_date; date_sub($transplant_date,date_interval_create_from_date_string("$days_to_harvest days")); date_add($transplant_date,date_interval_create_from_date_string("$resolution days")); } //end harvest date if ($method_id == 1 && $direct_sow_date != null){ date_add($direct_sow_date,date_interval_create_from_date_string("$days_to_harvest days")); date_add($direct_sow_date,date_interval_create_from_date_string("$resolution days")); $curcrop['EndHarvest'] = $direct_sow_date; date_sub($direct_sow_date,date_interval_create_from_date_string("$days_to_harvest days")); date_sub($direct_sow_date,date_interval_create_from_date_string("$resolution days")); date_add($direct_sow_date,date_interval_create_from_date_string("$date_int days")); } if ($method_id == 2 && $transplant_date != null){ date_add($transplant_date,date_interval_create_from_date_string("$days_to_harvest days")); date_add($transplant_date,date_interval_create_from_date_string("$resolution days")); $curcrop['EndHarvest'] = $transplant_date; date_sub($transplant_date,date_interval_create_from_date_string("$days_to_harvest days")); date_sub($transplant_date,date_interval_create_from_date_string("$resolution days")); date_add($transplant_date,date_interval_create_from_date_string("$date_int days")); } $crops[] = $curcrop; } echo json_encode($crops); ?> grid_data1.php
  3. i have dates in mysql database : 03/09/2013 05/09/2013 06/09/2013 09/09/2013 these dates stored in database. i am not getting how to get missing dates from the table???
  4. Hello folks, I have a little problem with dates. I have stored in my SQL table a 'date' type column as `birthday`. Something like that: (YYYY-MM-DD) 2010-05-10 2008-08-14 2002-03-04 2001-04-19 Now I'm trying to show the birthdays that will occur more 3 days/this week/this month. I know how to display the specific date by: $month = '10'; $day = '22'; $sql = $db->Query("SELECT `id` FROM `users` WHERE DATE_FORMAT(`birthday`,'%m') = '{$month}' AND DATE_FORMAT(`birthday`,'%d') = '{$day}'") or die(mysql_error()); I am aware of the function strtotime. But I need to show all the birthdays that will occur more 3 days including the tomorrow and the day after tomorrow dates.. and I'm a little bit get complex with it. Thanks for the help, appriciate it.
×
×
  • 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.