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 8695371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:01:03+00:00 2026-06-13T01:01:03+00:00

I have the following scenario where I have a datetime that I would like

  • 0

I have the following scenario where I have a datetime that I would like to reparse. I can get the following to work in irb, but I seem to be having an issue with nil values when working with post parameters. for ex.

This works in irb:

DateTime.strptime("10/25/2012 04:27 pm", "%m/%d/%Y %I:%M %P").strftime("%Y-%m-%d %H:%M:00")
=> "2012-10-25 16:27:00"

However when I try to access a params value I can’t seem to access the value itself. for ex.

def create
  @shipment = params[:shipment]
  @shipment.ship_date = format_date(@shipment.ship_date)
  .
  .
  .
 end     

def format_date(date)
  DateTime.strptime(date, "%m/%d/%Y %I:%M %P").strftime("%Y-%m-%d %H:%M:00")
end 

When I set a variable manually with a string it works. When I try to work off the parameter it seems to be nil. even when I do @shipment.ship_date.to_s it converts it to “” I know that parameter is not empty as it shows in the web inspector of my browser. I must not know how to work with parameter values.

  • 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-13T01:01:04+00:00Added an answer on June 13, 2026 at 1:01 am
    format_date(params["shipment"]["ship_date"])
    

    should work

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

Sidebar

Related Questions

i have following scenario and can't seem to find anything on the net, or
I have the following scenario: A Service that does nothing but sleeps for the
I have the following scenario, a Customer who can have bank accounts in several
I have the following scenario: A Doctor can have multiple Companions . A Companion
I have the following scenario: public interface IParam { Object Value {get;set;} } public
I have following scenario: I have a XML-Document, e.g. like this <someRootElement> <tag1> <tag2
I have the following classes which I would like to map using NHibernate class
I have implemented jquery date picker, but I'm struggling with parsing datetime value. Scenario
I have the following scenario and would be grateful for any advice how to
I have the following scenario public class Foo { public Bar FooBar { get;

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.