<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Gravity Support Forums Topic: Dynamically Populating Date Field</title>
		<link>https://legacy.forums.gravityhelp.com/topic/dynamically-populating-date-field</link>
		<description>Gravity Support Forums Topic: Dynamically Populating Date Field</description>
		<language>en-US</language>
		<pubDate>Thu, 09 Apr 2026 07:47:05 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.1</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>https://legacy.forums.gravityhelp.com/search.php</link>
		</textInput>
		<atom:link href="https://legacy.forums.gravityhelp.com/rss/topic/dynamically-populating-date-field" rel="self" type="application/rss+xml" />

		<item>
			<title>theslink2000 on "Dynamically Populating Date Field"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/dynamically-populating-date-field#post-72636</link>
			<pubDate>Sun, 26 Aug 2012 03:42:41 +0000</pubDate>
			<dc:creator>theslink2000</dc:creator>
			<guid isPermaLink="false">72636@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;No worries bud.  Hope someone finds it useful.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Chris Hajer on "Dynamically Populating Date Field"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/dynamically-populating-date-field#post-72620</link>
			<pubDate>Sun, 26 Aug 2012 00:51:51 +0000</pubDate>
			<dc:creator>Chris Hajer</dc:creator>
			<guid isPermaLink="false">72620@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;We'll leave it open.  Thanks for posting how you resolved your problem.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>theslink2000 on "Dynamically Populating Date Field"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/dynamically-populating-date-field#post-72600</link>
			<pubDate>Sat, 25 Aug 2012 12:01:37 +0000</pubDate>
			<dc:creator>theslink2000</dc:creator>
			<guid isPermaLink="false">72600@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I've worked it out, there was a syntax error, my bad!  I tried for hours before posting here, sorry.&#60;/p&#62;
&#60;p&#62;For anyone wondering Gravity Forms and I'm assuming Wordpress and PHP and SQL in general store dates as timestamps.  This is what threw me as the time stamp is the number of seconds since 00:00 01/01/1970 the timestamp was created.  Sounds weird but that's what date() does, it decodes this.&#60;/p&#62;
&#60;p&#62;To complete my editing code I needed to modify the after_submission function to this:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;//Update the existing monitor dosage system type post on submitting the form
function update_dob($entry) {
	 $timestamp = strtotime($entry[2]);
	 update_post_meta($entry[1], &#38;quot;wpcf-patient-date-of-birth&#38;quot;, $timestamp);  //Update the post (stored in field 1), field name and the new value (stored in field 3)
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Note the use of the strtotime() function to create the new timestamp.  Once this is done it's working beautifully.&#60;/p&#62;
&#60;p&#62;The above code is now correct and is working for me.  It's up to the admins if they want to delete this thread or not as I've sorted myself out, but I couldn't find this in the documentation so it may prove useful.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>theslink2000 on "Dynamically Populating Date Field"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/dynamically-populating-date-field#post-72592</link>
			<pubDate>Sat, 25 Aug 2012 11:08:24 +0000</pubDate>
			<dc:creator>theslink2000</dc:creator>
			<guid isPermaLink="false">72592@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi,&#60;/p&#62;
&#60;p&#62;I'm trying to dynamically populate a date field so that the user can see the existing entry and then update it using the date field (with date picker) as normal.  &#60;/p&#62;
&#60;p&#62;This process has not been a problem for every other field type I've tried and I'm sure it's not for the Date Field, however I can populate the field but the field isn't interpreting the data as I expected.  I've used a date field to save the data (in this case the original date is 08/12/1965 and that's how it outputs around the site, but the database stores it as -128304000. Obviously this must be correct as everything else seems to understand it, so I expected when I passed it back to the Date Field as a string it would understand it and convert it, but it doesn't it just displays -128304000.&#60;/p&#62;
&#60;p&#62;I can find no mention of this in the documentation or elsewhere in these forums, could someone help me interpret this please? &#60;/p&#62;
&#60;p&#62;Here's my code, as you can see I've tried using the php date() function, but to no effect:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;add_filter(&#38;#39;gform_field_value_original_dob&#38;#39;, &#38;#39;original_dob&#38;#39;);  //Dynamically populate the original dob field
//Populate the original date of birth edit field
function original_dob() {
	$post_id = $_GET[&#38;#39;original_post_id&#38;#39;];  //Pass GET function to pull variable from query string
	$post_field = &#38;quot;-date-of-birth&#38;quot;;  //Supply the bit of the field name specific to this item
	$data = populate_edit_field($post_id, $post_field);  //Build full funtion to find the required item of data
	$date = date(&#38;#39;d/m/Y&#38;#39;, $data);
	return $date;
}

//Function to build the command to and find the field data
function populate_edit_field ($post_id, $post_field) {
	$post_type = get_post_type($post_id);  //Use get_post_type to find the type of post, this is used as the part of the field name that changes for each type, such as &#38;quot;wpcf-surgery-street-address&#38;quot;
	$database_field = &#38;quot;wpcf-&#38;quot; . $post_type . $post_field;  //Build complete field name
	$post_data = find_post_data($post_id, $database_field, true);  //Finally find the contents of the field and post it back to the form
	return $post_data;
}

//Retrieve post meta based on the post id passed via query string to the form
function find_post_data($postid, $fieldname, $returntype) {
	global $post;  //Call the global $post variable to access stored data
	$value = get_post_meta($postid, $fieldname, $returntype);  //Return the contents of the requested field for the passed post id
	return $value;
}

add_action(&#38;quot;gform_after_submission_26&#38;quot;, &#38;quot;update_dob&#38;quot;, 10, 2);  //Update the edited date of birth in the database
//Update the existing monitor dosage system type post on submitting the form
function update_dob($entry) {
	 update_post_meta($entry[1], &#38;quot;wpcf-patient-date-of-birth&#38;quot;, $entry[2]);  //Update the post (stored in field 1), field name and the new value (stored in field 3)
}&#60;/code&#62;&#60;/pre&#62;</description>
		</item>

	</channel>
</rss>
