LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
LinkBack Search this Thread
Old 06-15-2012, 01:48 PM   #1
j-me
Member
 
Registered: Jan 2003
Location: des moines, ia
Distribution: suse RH
Posts: 117

Rep: Reputation: 16
convert string date to numeric


I have a date I obtain from a cert:

Apr 13 2022

That I need to convert to a numeric so I can compare to the current date+60 and find all the will expire in 60 days or less
[<=]

[this is SuSe 10.1 so unfortunately, convdate is not available]
 
Old 06-15-2012, 02:00 PM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Location: the Netherlands
Distribution: lfs, debian, rhel
Posts: 8,714
Blog Entries: 8

Rep: Reputation: 1627Reputation: 1627Reputation: 1627Reputation: 1627Reputation: 1627Reputation: 1627Reputation: 1627Reputation: 1627Reputation: 1627Reputation: 1627Reputation: 1627
You don't mention a specific (script) language, here's a way using the date command:
Code:
date --date="Apr 13 2022" '+%Y%m%d'

$ date --date="Apr 13 2022" '+%Y%m%d'
20220413
 
1 members found this post helpful.
Old 06-15-2012, 02:00 PM   #3
Skaperen
Senior Member
 
Registered: May 2009
Location: WV, USA
Distribution: Slackware, Debian, EasyPeasy, Ubuntu, Fedora, Timesys, Linux From Scratch
Posts: 1,671
Blog Entries: 20

Rep: Reputation: 111Reputation: 111
Are you working at the scripting level?

Code:
lorentz/phil /home/phil 1148> date -d 'apr 13 2022'
Wed Apr 13 00:00:00 EDT 2022
lorentz/phil /home/phil 1149>
Are you working at the C/C++ level?

Code:
man 3 getdate
 
Old 06-15-2012, 02:03 PM   #4
j-me
Member
 
Registered: Jan 2003
Location: des moines, ia
Distribution: suse RH
Posts: 117

Original Poster
Rep: Reputation: 16
sorry

bash

that works. thanks
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL -any value for numeric or string field nocturna_gr Programming 2 02-12-2010 10:53 AM
Split string and numeric with perl kariagekun Programming 4 11-05-2009 07:31 PM
problem in comparing numeric with string naren_0101bits Programming 1 01-28-2008 08:10 AM
Java - Convert String to Date and back Kamikazee Programming 1 04-27-2006 02:52 AM
convert date time format given in string suchi_s Programming 6 01-10-2005 04:06 AM


All times are GMT -5. The time now is 07:36 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration