Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8784777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:11:23+00:00 2026-06-13T21:11:23+00:00

I’m currently in the process of switching from ActiveRecord’s as_json to RABL for API

  • 0

I’m currently in the process of switching from ActiveRecord’s as_json to RABL for API generation.

as_json has been rendering timestamps in my models as strings of the format 2012-09-16T22:14:11+00:00. However, when I switched to RABL timestamps started rendering as epoch numbers like 1347926218.084763000 (note these dates are from two different objects and are not supposed to be equal). Is there a way to force the string format?

My .rabl template is pretty simple:

object @person
attributes :id, :created_on, :name

and I get:

{"id":3,"created_on":1347926218.084763000,"name":"fred"}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T21:11:24+00:00Added an answer on June 13, 2026 at 9:11 pm
     object @person
       node(:id){|person|(person.id)}
       node(:created_on){|person|(person.created_on.strftime(%d,%m,%Y)}
       node(:name){|person|(person.name)}
     end
    

    or try

     object @person
       attributes :id, :name
       node(:created_on){|person|(person.created_on.strftime(%d,%m,%Y)}
     end
    

    There are more options for .strftime() you can find on many sites. It must be used on a :date object type. You can customize the date output with it’s options. I’m working on custom nodes for some json output and am learning this the hard way!

    If you need the the attributes in a certain order I’d use the one with nodes because the attributes seem to ‘float to the top’ of the json object created.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.