Search code examples
dateschema.orgjson-ld

Can I set an endDate to n/a in Schema.org SaleEvent?


I am trying to find the correct way of setting the endDate in a Schema.org SaleEvent.

Right now this is what I am doing, but I'm wondering if this is the correct way? I'm actually still waiting for Google to show these results, so I can't test if it works yet.

<script type="application/ld+json">
{
    "@context": "http://schema.org",
    "@type": "SaleEvent",
    "name": "<?=$obj->title;?>",
    "url": "<?=$fun_domain.'/'.$fun_shop_page.'/'.$shop_slug;?>",
    "startDate": "<?=date("Y-m-d",$obj->ctime);?>",
    <?if(!empty($obj->expiredate)){echo'"endDate": "'.date("Y-m-d",$obj->expiredate).'",';}?>
    "location": {
        "@type": "Place",
        "name": "<?=$shop_name;?>",
        "url": "<?=$shop_home_url;?>",
        "address": "<?=$shop_name;?>"
    }
}
</script>

Solution

  • If you don't want to provide an end date, omit it completely rather than setting an invalid value. This seems to be what your code is doing, but the title of your question seems to indicate otherwise. Your code as it is now would appear to be correct.