WC_Log_Handler_DB::delete_logs_before_timestamp()public staticWC 3.4.0

Delete all logs older than a defined timestamp.

{} It's a method of the class: WC_Log_Handler_DB{}

No Hooks.

Return

null. Nothing.

Usage

$result = WC_Log_Handler_DB::delete_logs_before_timestamp( $timestamp );
$timestamp(int)
Timestamp to delete logs before.

Changelog

Since 3.4.0 Introduced.

Code of WC_Log_Handler_DB::delete_logs_before_timestamp() WC 6.8.2

public static function delete_logs_before_timestamp( $timestamp = 0 ) {
	if ( ! $timestamp ) {
		return;
	}

	global $wpdb;

	$wpdb->query(
		$wpdb->prepare(
			"DELETE FROM {$wpdb->prefix}woocommerce_log WHERE timestamp < %s",
			date( 'Y-m-d H:i:s', $timestamp )
		)
	);
}