Showing posts with label Date. Show all posts
Showing posts with label Date. Show all posts

Thursday 5 May 2016

How to Shopify API Product / Order / Collection get sorted when passing in an created_at / updated_at filter

What would be ideal would be to be able to get results in ascending/descending order one way or another, but without having to pass in since_id, because we want to be able to pull in new data on orders on an ongoing basis as they may be updated.

Its possible to sort the Products/Orders/Collection by passing an "order" parameter. The "order" parameter should contain the field to sort by (supported fields are "created_at", "updated_at" and "processed_at"), followed by a space and then by an "asc" or "desc".

Please check following Example for solution.

https://example.myshopify.com/admin/orders.json?limit=2&fields=id,created_at&order=created_at%20asc

Saturday 9 April 2016

How to get last week' date range in PHP, Codeigniter, CakePHP

$previous_week = strtotime("-1 week +1 day");
$start_week = strtotime("last sunday midnight",$previous_week);
$end_week = strtotime("next saturday",$start_week);
$start_week = date("Y-m-d",$start_week);
$end_week = date("Y-m-d",$end_week);
echo $start_week.' '.$end_week ;