Title: &#8220;Customer Since&#8221; code/function that outputs the date?
Last modified: October 31, 2022

---

# “Customer Since” code/function that outputs the date?

 *  Resolved [Sho-Down](https://wordpress.org/support/users/sho-down/)
 * (@sho-down)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/customer-since-code-function-that-outputs-the-date/)
 * I’m setting up an Account page for customers and I like how you guys did the 
   EDD website’s account dashboard. Is there a code/function for “Customer Since”
   that outputs a formatted date?
 * I found the code for number of total purchases:
    `<?php echo edd_count_purchases_of_customer();?
   >`
 * And the code for total value of purchases on Andrew’s site from 2015 (is there
   an easier way to output this besides using Andrew’s method?):
    [https://andrew.dev/easy-digital-downloads-show-how-much-customer-has-spent](https://andrew.dev/easy-digital-downloads-show-how-much-customer-has-spent)
 * I just can’t find the code for Customer Since. Thanks!
    -  This topic was modified 3 years, 7 months ago by [Sho-Down](https://wordpress.org/support/users/sho-down/).

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Contributor [Mihai Joldis](https://wordpress.org/support/users/misulicus/)
 * (@misulicus)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/customer-since-code-function-that-outputs-the-date/#post-16148601)
 * Hey [@sho-down](https://wordpress.org/support/users/sho-down/)
 * For the Customer since field, you can use the `$custoner->date_created` method.
   
   Perhaps something like this to get the date:
 *     ```
       $customer_since_date = substr( $customer->date_created, 0, strpos( $customer->date_created, ' ' ) );
       $customer_since = date( 'F j, Y', str_replace( '-', '/', strtotime( $customer_since_date ) ) );
       ```
   
 * Something similar can be done for the purchase value as that is now stored in
   the Customer table:
 *     ```
       echo edd_currency_filter( edd_format_amount( $customer->purchase_value ) );
       ```
   
 *  Thread Starter [Sho-Down](https://wordpress.org/support/users/sho-down/)
 * (@sho-down)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/customer-since-code-function-that-outputs-the-date/#post-16149469)
 * ah that’s a bit over my head [@misulicus](https://wordpress.org/support/users/misulicus/),
   I could use little more help if you wouldn’t mind, if not I understand.
 * I don’t know how to put that in my custom template page file for it to output
   the formatted date. I can’t do:
 *     ```
       <?php $customer_since_date = substr( $customer->date_created, 0, strpos( $customer->date_created, ' ' ) );
       $customer_since = date( 'F j, Y', str_replace( '-', '/', strtotime( $customer_since_date ) ) );
       ?>
       ```
   
 * I looked in customers.php and found this but it outputs **December 31, 1969**:
 *     ```
       <span class="customer-since info-item editable">
       <?php printf(
       /* translators: The date. */
       esc_html__( '%s', 'easy-digital-downloads' ),
       esc_html( edd_date_i18n( $customer->date_created ) )
       ); ?>
       </span>
       ```
   
 * And this just outputs $0.00:
 * `<?php echo edd_currency_filter( edd_format_amount( $customer->purchase_value));?
   >`
 * Do I need to put some code in my functions.php file and call it from there?
 *  Plugin Contributor [Mihai Joldis](https://wordpress.org/support/users/misulicus/)
 * (@misulicus)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/customer-since-code-function-that-outputs-the-date/#post-16159990)
 * Hey [@sho-down](https://wordpress.org/support/users/sho-down/)
 * You will need to get the `$customer` object first in order to access that data.
   Posting a code snippet below but you might need to adjust it based on your needs.
   
   If you need assistance with this is best to reach out to a developer:
 *     ```
       $customer = '';
       if ( is_user_logged_in() ) {
       	$current_user = wp_get_current_user();
   
       	if ( class_exists( 'Easy_Digital_Downloads' ) ) {
       		$customer = new EDD_Customer( $current_user->ID, true );
       	}
   
       	if ( ! empty( $customer->id ) ) {
       		$customer_since_date = substr( $customer->date_created, 0, strpos( $customer->date_created, ' ' ) );
       		$customer_since = date( 'F j, Y', str_replace( '-', '/', strtotime( $customer_since_date ) ) );
   
       		echo $customer_since; //This prints the Customer creation date
   
       		echo edd_currency_filter( edd_format_amount( $customer->purchase_value ) ); // This prints the customer's purchase value
       	}
       }
       ```
   
    -  This reply was modified 3 years, 7 months ago by [Mihai Joldis](https://wordpress.org/support/users/misulicus/).
 *  Thread Starter [Sho-Down](https://wordpress.org/support/users/sho-down/)
 * (@sho-down)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/customer-since-code-function-that-outputs-the-date/#post-16165228)
 * Thanks so much [@misulicus](https://wordpress.org/support/users/misulicus/) that
   works in my page template, I just had to add an additional bracket at the end:
 *     ```
       <?php $customer = ''; ?>
       <?php if ( is_user_logged_in() ) {
       	$current_user = wp_get_current_user();
   
       	if ( class_exists( 'Easy_Digital_Downloads' ) ) {
       		$customer = new EDD_Customer( $current_user->ID, true );
       	}
   
       	if ( ! empty( $customer->id ) ) {
       		$customer_since_date = substr( $customer->date_created, 0, strpos( $customer->date_created, ' ' ) );
       		$customer_since = date( 'F j, Y', str_replace( '-', '/', strtotime( $customer_since_date ) ) );
   
       		echo $customer_since; //This prints the Customer creation date
   
       		echo edd_currency_filter( edd_format_amount( $customer->purchase_value ) ); // This prints the customer's purchase value
       	}
       }
       ?>
       ```
   

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘“Customer Since” code/function that outputs the date?’ is closed to new
replies.

 * ![](https://ps.w.org/easy-digital-downloads/assets/icon.svg?rev=3455837)
 * [Easy Digital Downloads – eCommerce Payments and Subscriptions made easy](https://wordpress.org/plugins/easy-digital-downloads/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/easy-digital-downloads/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/easy-digital-downloads/)
 * [Active Topics](https://wordpress.org/support/plugin/easy-digital-downloads/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/easy-digital-downloads/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/easy-digital-downloads/reviews/)

## Tags

 * [EDD](https://wordpress.org/support/topic-tag/edd/)
 * [function](https://wordpress.org/support/topic-tag/function/)

 * 4 replies
 * 2 participants
 * Last reply from: [Sho-Down](https://wordpress.org/support/users/sho-down/)
 * Last activity: [3 years, 7 months ago](https://wordpress.org/support/topic/customer-since-code-function-that-outputs-the-date/#post-16165228)
 * Status: resolved