# Format

Format filters apply formats to specific data types.

## date

`string | date: string`

returns  [string](../basics/liquid-types#string)

Converts a timestamp into another date format.

The date filter accepts the same parameters as PHP `strftime` method for formatting the date. For a list of shorthand formats, refer to the [PHP documentation](https://www.php.net/manual/en/function.strftime.php).

**Code**

```liquid
{{ '2023-06-15 15:11:02' | date: '%B %d, %Y' }}
```

**Output**

```text
June 15, 2023
```

### The current date

You can apply the `date` filter to the keywords `'now'` and `'today'` to output the current timestamp.

**note**

The timestamp will reflect the time that the Liquid was last rendered. Because of this, the timestamp might not be updated for every page view, depending on the context and caching.

**Code**

```liquid
{{ 'now' | date: '%B %d, %Y %H:%M:%S' }}
```

**Output**

```html
June 15, 2023 15:23:57
```

### The future or past date

You can apply the same parameters as the [PHP strtotime](https://www.php.net/manual/en/function.strtotime.php) method to output any English textural date.

**Code**

```liquid
{{ '+7 day' | date: '%B %d, %Y' }}
```

**Output**

```text
June 22, 2023
```

## Format Unix timestamp

You can apply the `date` filter to the keywords `r` for formatting a Unix timestamp.

**Code**

```liquid
{{ 'now' | date: 'r' }}
```

**Output**

```text
Thu, 15 Jun 2023 15:32:06 +0800
```

## json

`variable | join`

returns  [string](../basics/liquid-types#string)

Converts a string, or an object, into JSON format.

**tip**

When using the JSON output in JavaScript, you don't need to wrap it in quotes because the `json` filter includes them. The `json` filter also escapes any quotes inside the output.

**Code**

```liquid
{{ product | json }}
```

**Output**

```json
{
  "id": "0f0eaab1-afaa-4bf2-b1d9-993f10c2c63e",
  "title": "Lace-up Leather Manston Runner",
  "brief": "",
  "description": "<p>Sporty yet sophisticated, this short-sleeve ribbed crewneck is made from super-fine Egyptian cotton with stretch that hugs in all the right places. Finished with varsity stripe detail on the cuff and hem.<br /><br />55% linen, 45% cotton<br />oversized relax fit <br />cotton herringbone drawcord<br />cold delicate machine wash<br />Model is 177cm, wearing size S.<br /><br />This is a demo store. You can purchase products like this from <a href=\"https://www.rag-bone.com\" target=\"_blank\" rel=\"noopener noreferrer\">rag&amp;bone</a>.</p>",
  "vendor": "Nero",
  "vendor_url": "",
  "has_only_default_variant": false,
  "requires_shipping": true,
  "taxable": false,
  "inventory_policy": "deny",
  "inventory_quantity": 540,
  "inventory_tracking": true,
  "published": true,
  "handle": "lace-up-leather-manston-runner",
  "spu": "",
  "note": "",
  "need_variant_image": false,
  "fake_sales": 0,
  "display_fake_sales": false,
  "independent_seo": false,
  "updated_at": "2023-06-19T01:11:44Z",
  "created_at": "2021-08-23T01:24:46Z",
  "mixed_wholesale": false,
  "product_type": "",
  "tags": "Color_Black,Color_Crimson,Color_Indianred,Location_Louisiana,Price_$300-$400",
  "available": true,
  "price_min": "325",
  "price": "325",
  "price_max": "358",
  "compare_at_price_min": "0",
  "compare_at_price": "0",
  "compare_at_price_max": "388",
  "retail_price_min": "0",
  "retail_price_max": "388",
  "url": "/products/lace-up-leather-manston-runner",
  "published_at": "2021-10-21T06:51:30Z",
  "sales": 0,
  "image": {
    "src": "//cdn.shoplazza.com/5afeee913a4f8ff183295949f8e9d129.jpeg",
    "path": "5afeee913a4f8ff183295949f8e9d129.jpeg",
    "width": 1280,
    "height": 1710,
    "alt": "",
    "aspect_ratio": 0.7485380116959064
  },
  "meta_title": "Lace-up Leather Manston Runner",
  "meta_description": "Sporty yet sophisticated, this short-sleeve ribbed crewneck is made from super-fine Egyptian cotton with stretch that hugs in all the right places. Finished with varsity stripe detail on the cuff and hem.<br><br>55% linen, 45% cotton<br>oversized relax fit <br>cotton herringbone drawcord<br>cold delicate machine wash<br>Model is 177cm, wearing size S.<br><br>This is a demo store. You can purchase products like this from <a href=\"https://www.rag-bone.com\" target=\"_blank\" rel=\"noopener noreferrer\">rag&amp;bone</a>.",
  "meta_keyword": "",
  "options": [
    {
      "id": "6747f563-d35e-43da-9c16-1de70478f07e",
      "name": "Color",
      "position": 1,
      "values": [
        "DarkRed"
      ]
    },
    {
      "id": "8f2584b4-3ded-4820-b060-403b81f1150f",
      "name": "Size",
      "position": 2,
      "values": [
        "35",
        "36",
        "37",
        "38",
        "39",
        "40"
      ]
    }
  ],
  "variants": [
    {
      "id": "d7e63bd8-d066-4ba0-9c4f-e206bba7bc59",
      "product_id": "0f0eaab1-afaa-4bf2-b1d9-993f10c2c63e",
      "title": "DarkRed-35",
      "weight_unit": "g",
      "inventory_quantity": 90,
      "sku": "WFF19FF0321D32-1",
      "barcode": "",
      "position": 1,
      "option1": "DarkRed",
      "option2": "35",
      "option3": "",
      "note": "",
      "image": null,
      "wholesale_price": [
        {
          "price": 358,
          "min_quantity": 1
        }
      ],
      "weight": "568",
      "compare_at_price": "388",
      "price": "358",
      "retail_price": "388",
      "available": true,
      "url": "/products/lace-up-leather-manston-runner?variant=d7e63bd8-d066-4ba0-9c4f-e206bba7bc59",
      "available_quantity": 90,
      "options": [
        {
          "name": "Color",
          "value": "DarkRed"
        },
        {
          "name": "Size",
          "value": "35"
        }
      ],
      "off_ratio": 8,
      "flashsale_info": [],
      "sales": 0
    },
    {
      "id": "12309f3f-71db-4e32-b564-1ff647bb43a7",
      "product_id": "0f0eaab1-afaa-4bf2-b1d9-993f10c2c63e",
      "title": "DarkRed-36",
      "weight_unit": "kg",
      "inventory_quantity": 90,
      "sku": "WFF19FF0321D32-2",
      "barcode": "",
      "position": 2,
      "option1": "DarkRed",
      "option2": "36",
      "option3": "",
      "note": "",
      "image": null,
      "wholesale_price": [
        {
          "price": 325,
          "min_quantity": 1
        }
      ],
      "weight": "0",
      "compare_at_price": "0",
      "price": "325",
      "retail_price": "0",
      "available": true,
      "url": "/products/lace-up-leather-manston-runner?variant=12309f3f-71db-4e32-b564-1ff647bb43a7",
      "available_quantity": 90,
      "options": [
        {
          "name": "Color",
          "value": "DarkRed"
        },
        {
          "name": "Size",
          "value": "36"
        }
      ],
      "off_ratio": 0,
      "flashsale_info": [],
      "sales": 0
    },
    {
      "id": "1f5b0e25-50e1-4196-9bee-25d825cd3ca9",
      "product_id": "0f0eaab1-afaa-4bf2-b1d9-993f10c2c63e",
      "title": "DarkRed-37",
      "weight_unit": "kg",
      "inventory_quantity": 90,
      "sku": "WFF19FF0321D32-3",
      "barcode": "",
      "position": 3,
      "option1": "DarkRed",
      "option2": "37",
      "option3": "",
      "note": "",
      "image": null,
      "wholesale_price": [
        {
          "price": 325,
          "min_quantity": 1
        }
      ],
      "weight": "0",
      "compare_at_price": "0",
      "price": "325",
      "retail_price": "0",
      "available": true,
      "url": "/products/lace-up-leather-manston-runner?variant=1f5b0e25-50e1-4196-9bee-25d825cd3ca9",
      "available_quantity": 90,
      "options": [
        {
          "name": "Color",
          "value": "DarkRed"
        },
        {
          "name": "Size",
          "value": "37"
        }
      ],
      "off_ratio": 0,
      "flashsale_info": [],
      "sales": 0
    },
    {
      "id": "b11e6ff8-b8ed-4b4c-a531-dbd8c923d813",
      "product_id": "0f0eaab1-afaa-4bf2-b1d9-993f10c2c63e",
      "title": "DarkRed-38",
      "weight_unit": "kg",
      "inventory_quantity": 90,
      "sku": "WFF19FF0321D32-4",
      "barcode": "",
      "position": 4,
      "option1": "DarkRed",
      "option2": "38",
      "option3": "",
      "note": "",
      "image": null,
      "wholesale_price": [
        {
          "price": 325,
          "min_quantity": 1
        }
      ],
      "weight": "0",
      "compare_at_price": "0",
      "price": "325",
      "retail_price": "0",
      "available": true,
      "url": "/products/lace-up-leather-manston-runner?variant=b11e6ff8-b8ed-4b4c-a531-dbd8c923d813",
      "available_quantity": 90,
      "options": [
        {
          "name": "Color",
          "value": "DarkRed"
        },
        {
          "name": "Size",
          "value": "38"
        }
      ],
      "off_ratio": 0,
      "flashsale_info": [],
      "sales": 0
    },
    {
      "id": "5e1e5f57-93eb-4909-a696-2516aa25cb44",
      "product_id": "0f0eaab1-afaa-4bf2-b1d9-993f10c2c63e",
      "title": "DarkRed-39",
      "weight_unit": "kg",
      "inventory_quantity": 90,
      "sku": "WFF19FF0321D32-5",
      "barcode": "",
      "position": 5,
      "option1": "DarkRed",
      "option2": "39",
      "option3": "",
      "note": "",
      "image": null,
      "wholesale_price": [
        {
          "price": 325,
          "min_quantity": 1
        }
      ],
      "weight": "0",
      "compare_at_price": "0",
      "price": "325",
      "retail_price": "0",
      "available": true,
      "url": "/products/lace-up-leather-manston-runner?variant=5e1e5f57-93eb-4909-a696-2516aa25cb44",
      "available_quantity": 90,
      "options": [
        {
          "name": "Color",
          "value": "DarkRed"
        },
        {
          "name": "Size",
          "value": "39"
        }
      ],
      "off_ratio": 0,
      "flashsale_info": [],
      "sales": 0
    },
    {
      "id": "bc0cb233-e393-478f-8c44-a652a30bfafb",
      "product_id": "0f0eaab1-afaa-4bf2-b1d9-993f10c2c63e",
      "title": "DarkRed-40",
      "weight_unit": "kg",
      "inventory_quantity": 90,
      "sku": "WFF19FF0321D32-6",
      "barcode": "",
      "position": 6,
      "option1": "DarkRed",
      "option2": "40",
      "option3": "",
      "note": "",
      "image": null,
      "wholesale_price": [
        {
          "price": 325,
          "min_quantity": 1
        }
      ],
      "weight": "0",
      "compare_at_price": "0",
      "price": "325",
      "retail_price": "0",
      "available": true,
      "url": "/products/lace-up-leather-manston-runner?variant=bc0cb233-e393-478f-8c44-a652a30bfafb",
      "available_quantity": 90,
      "options": [
        {
          "name": "Color",
          "value": "DarkRed"
        },
        {
          "name": "Size",
          "value": "40"
        }
      ],
      "off_ratio": 0,
      "flashsale_info": [],
      "sales": 0
    }
  ],
  "images": [
    {
      "src": "//cdn.shoplazza.com/5afeee913a4f8ff183295949f8e9d129.jpeg",
      "path": "5afeee913a4f8ff183295949f8e9d129.jpeg",
      "width": 1280,
      "height": 1710,
      "alt": "",
      "aspect_ratio": 0.7485380116959064
    },
    {
      "src": "//cdn.shoplazza.com/44cf329e8f4ebe6a2b4b9cc29674c181.jpeg",
      "path": "44cf329e8f4ebe6a2b4b9cc29674c181.jpeg",
      "width": 1280,
      "height": 1710,
      "alt": "",
      "aspect_ratio": 0.7485380116959064
    },
    {
      "src": "//cdn.shoplazza.com/f4d670f4175e188a3cb9b0449f0ca00d.jpeg",
      "path": "f4d670f4175e188a3cb9b0449f0ca00d.jpeg",
      "width": 1280,
      "height": 1710,
      "alt": "",
      "aspect_ratio": 0.7485380116959064
    },
    {
      "src": "//cdn.shoplazza.com/c2ff6094baab824afde797a364384813.jpeg",
      "path": "c2ff6094baab824afde797a364384813.jpeg",
      "width": 1280,
      "height": 1710,
      "alt": "",
      "aspect_ratio": 0.7485380116959064
    },
    {
      "src": "//cdn.shoplazza.com/9ca7f7e1857fd33df730497b9407bd6d.jpeg",
      "path": "9ca7f7e1857fd33df730497b9407bd6d.jpeg",
      "width": 1280,
      "height": 1710,
      "alt": "",
      "aspect_ratio": 0.7485380116959064
    },
    {
      "src": "//cdn.shoplazza.com/7b4061544a337676e02e97d0bdc7b468.jpeg",
      "path": "7b4061544a337676e02e97d0bdc7b468.jpeg",
      "width": 1280,
      "height": 1710,
      "alt": "",
      "aspect_ratio": 0.7485380116959064
    },
    {
      "src": "//cdn.shoplazza.com/48a60cb49a67a5677e258211b4b03be0.jpeg",
      "path": "48a60cb49a67a5677e258211b4b03be0.jpeg",
      "width": 1280,
      "height": 1710,
      "alt": "",
      "aspect_ratio": 0.7485380116959064
    }
  ],
  "redirect": false,
  "redirect_url": "",
  "retail_price": "0",
  "price_varies": false,
  "off_ratio": 0,
  "flashsale_info": []
}
```

### Exclude specific properties

`variable | join: string`

returns  [string](../basics/liquid-types#string)

You can specify a comma-separated string to indicate the content of the property that does not contain.

**Code**

```liquid
{{ product | json: 'variants,options,images' }}
```

**Output**

```json
{
  "id": "0f0eaab1-afaa-4bf2-b1d9-993f10c2c63e",
  "title": "Lace-up Leather Manston Runner",
  "brief": "",
  "description": "Sporty yet sophisticated, this short-sleeve ribbed crewneck is made from super-fine Egyptian cotton with stretch that hugs in all the right places. Finished with varsity stripe detail on the cuff and hem. 55% linen, 45% cotton oversized relax fit cotton herringbone drawcord cold delicate machine wash Model is 177cm, wearing size S. This is a demo store. You can purchase products like this from rag&bone<\/a>.",
  "vendor": "Nero",
  "vendor_url": "",
  "has_only_default_variant": false,
  "requires_shipping": true,
  "taxable": false,
  "inventory_policy": "deny",
  "inventory_quantity": 540,
  "inventory_tracking": true,
  "published": true,
  "handle": "lace-up-leather-manston-runner",
  "spu": "",
  "note": "",
  "need_variant_image": false,
  "fake_sales": 0,
  "display_fake_sales": false,
  "independent_seo": false,
  "updated_at": "2021-10-21T06:51:30Z",
  "created_at": "2021-08-23T01:24:46Z",
  "mixed_wholesale": false,
  "tags": "Color_Black,Color_Crimson,Color_Indianred,Location_Louisiana,Price_$300-$400",
  "available": true,
  "price_min": "325",
  "price": "325",
  "price_max": "325",
  "compare_at_price_min": "0",
  "compare_at_price": "0",
  "compare_at_price_max": "0",
  "retail_price_min": "0",
  "retail_price_max": "0",
  "url": "\/products\/lace-up-leather-manston-runner",
  "published_at": "2021-10-21T06:51:30Z",
  "sales": 0,
  "image": {
    "src": "\/\/img.staticdj.com\/5afeee913a4f8ff183295949f8e9d129.jpeg",
    "path": "5afeee913a4f8ff183295949f8e9d129.jpeg",
    "width": 1280,
    "height": 1710,
    "alt": "",
    "aspect_ratio": 0.7485380116959064
  },
  "meta_title": "Lace-up Leather Manston Runner",
  "meta_description": "Sporty yet sophisticated, this short-sleeve ribbed crewneck is made from super-fine Egyptian cotton with stretch that hugs in all the right places. Finished with varsity stripe detail on the cuff and hem. 55% linen, 45% cotton oversized relax fit cotton herringbone drawcord cold delicate machine wash Model is 177cm, wearing size S. This is a demo store. You can purchase products like this from rag&bone<\/a>.",
  "meta_keyword": "",
  "redirect": false,
  "redirect_url": "",
  "retail_price": "0",
  "price_varies": true,
  "off_ratio": 0,
  "flashsale_info": []
}
```

## weight\_with\_unit

`number | weight_with_unit`

returns  [string](../basics/liquid-types#string)

Generates a formatted weight for a [variant object](/docs/theme/references/liquid/objects/variant). The weight unit is set in the general settings in the [Shoplazza admin](https://sso.shoplazza.com/login).

**Code**

```liquid
{% assign variant = product.variants | first %}

{{ variant.weight | weight_with_unit }}
```

**Data**

```json
{
  "product": {
    "variants": [
      {
        "weight": 228
      },
      {
        "weight": 256
      },
      {
        "weight": 242
      },
      {
        "weight": 200
      }
    ]
  }
}
```

**Output**

```html
228 kg
```

### Override the default unit

`number | weight_with_unit: variable`

returns  [string](../basics/liquid-types#string)

You can specify a unit to override the default from the general settings.

**Code**

```liquid
{% assign variant = product.variants | first %}

{{ variant.weight | weight_with_unit: 'g' }}
```

**Data**

```json
{
  "product": {
    "variants": [
      {
        "weight": 228
      },
      {
        "weight": 256
      },
      {
        "weight": 242
      },
      {
        "weight": 200
      }
    ]
  }
}
```

**Output**

```html
228 g
```
