我想在以下模型中创建DateTimeCreated
和DateTimeUpdated
属性。我想在html页面上创建/编辑项目时隐藏用户的两个字段。 DateTimeCreated
属性应设置为用户浏览器的当前日期和时间(当用户第一次创建项目时),类似DateTimeUpdated
应设置为当前日期和时间每次用户编辑/更新项目时用户浏览器的浏览器。有没有一种简单的方法来实现它?
public class Project
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public DateTime DateTimeCreated { get; set; }
public DateTime DateTimeUpdated { get; set; }
}
答案 0 :(得分:2)
旧方式
extldi r11, r12, 31,17
或者
_.each(collection.models, function(element, index, list){
console.log(JSON.stringify(element)); //{"title":"Dipped Bunny Blossom","id":49,"created_at":"2015-03-24T10:16:17Z","updated_at":"2015-03-24T13:56:12Z","type":"simple","status":"publish","downloadable":false,"virtual":false,"permalink":"http://beta-it.com/ticarttest/shop/dipped-bunny-blossom/","sku":"","price":"50.00","regular_price":"50.00","sale_price":null,"price_html":"<span class=\"amount\">$50.00</span>","taxable":false,"tax_status":"taxable","tax_class":"","managing_stock":false,"stock_quantity":0,"in_stock":true,"backorders_allowed":false,"backordered":false,"sold_individually":false,"purchaseable":true,"featured":true,"visible":true,"catalog_visibility":"visible","on_sale":false,"weight":"1.00","dimensions":{"length":"50","width":"50","height":"50","unit":"cm"},"shipping_required":true,"shipping_taxable":true,"shipping_class":"","shipping_class_id":null,"description":"","short_description":"","reviews_allowed":true,"average_rating":"4.50","rating_count":2,"related_ids":[34,43,45,47,120],"upsell_ids":[],"cross_sell_ids":[],"parent_id":0,"categories":["BIRTHDAY","BUSINESS GIFTS","DIPPED FRUIT"],"tags":[],"images":[{"id":50,"created_at":"2015-03-03T10:16:10Z","updated_at":"2015-03-03T10:16:10Z","src":"http://beta-it.com/ticarttest/wp-content/uploads/2015/03/Dipped-Bunny-Blossom.jpg","title":"Dipped-Bunny-Blossom","alt":"","position":0}],"featured_src":"http://beta-it.com/ticarttest/wp-content/uploads/2015/03/Dipped-Bunny-Blossom.jpg","attributes":[],"downloads":[],"download_limit":0,"download_expiry":0,"download_type":"","purchase_note":"","total_sales":1,"variations":[],"parent":[]}
console.log(element.id); // return 49 ok
console.log(element.title); //return null !!!!
// We are looping through the returned models from the remote REST API
// Implement your custom logic here
});